I set up a Python virtual environment in 'Visual Studio Code'. Here is the full path to my python interpreter:
"C:\Users\Hamid\Desktop\VisualStudio.venv\Scripts\python.exe"
I am creating an Azure function. I have the following files in my folder:
In my requirements.txt file I have the names of the Python packages I need installed for my main Python script. When I run the following command in the terminal:
pip install -r requirements.txt
I get the following message:
Requirement already satisfied: azure-functions in c:\users\hamid\appdata\local\programs\python\python39\lib\site-packages (from -r requirements.txt (line 5)) (1.12.0)
The Terminal doesn't seem to be connected to my Virtual Python environment. How can I set the terminal up so that it connects to the virtual enviornment?.
I came across two suggestions on stackoverflow. I tried to manually set the python interpreter and I also pressed ctrl+shift+' to reset the terminal. Unfortunately both methods did not work for me.
One of the workarounds is to activate the virtual environment and change the function run path to virtual environment folder in the VS Code terminal:
python -m venv .venv
source .venv/bin/activate
OR
set-executionpolicy remotesigned
.venv\Scripts\Activate.ps1
OR
when you open the project in VS Code, you'll get the dialog box like below and click on yes:
and freeze the requirements file using the cmdlet
pip freeze > requirements.txt`
Refer to few of my workarounds SO Thread1 and Thread2 in regards of Virtual Environment activating in Azure Functions
Related
I tried to create virtual environment using pyenv virtualenv 3.8.2 myenv, but it failed, i don't know why, i even changed the python version or the virtual environment name, but it still not working.
Some detail:
I tried this in macos and zsh.
➜ ~ pyenv virtualenv 3.8.2 myenv
Looking in links: /var/folders/_9/l8m14fgs6ts9wx0nl1qbzbkm0000gn/T/tmpe9l25o2_
Requirement already satisfied: setuptools in /Users/fitz/.pyenv/versions/3.8.2/envs/myenv/lib/python3.8/site-packages (41.2.0)
Requirement already satisfied: pip in /Users/fitz/.pyenv/versions/3.8.2/envs/myenv/lib/python3.8/site-packages (19.2.3)
rm: /Users/fitz/.pyenv/shims/shims: is a directory
➜ ~ pyenv versions
system
3.7.3
* 3.8.2 (set by /Users/fitz/.python-version)
3.9.5
I had the same issue. For me it was caused by two empty folders in my shims directory. I deleted the folders and it fixed the issue. So, just running the following would fix your issue.
rm -rf ~/.pyenv/shims/shims
rm -rf ~/.pyenv/shims/versions
Try using 'venv' instead of pyenv or pyvenv or virtualenv. Venv is a library that already comes with your python installation. Virtualenv is an external one.pyenv is similar to venv in that it lets you manage multiple python environments. However with pyenv you can't conveniently rollback library installs to some start state and you will likely need admin privileges at some point to update libraries. So I think it is also best to use venv.
First, make a directory :
mkdir testing
Then, moved to this directory named testing :
cd testing
When you type following command in this directory:
python3 -m venv env
You got error like :
The virtual environment was not created successfully because ensurepip is not
available. On Debian/Ubuntu systems, you need to install the python3-venv
package using the following command.
apt install python3.8-venv
Type the following command but before that keep an eye on the version of python you installed on the machine; in my case its python3.8
sudo apt install python3.8-venv
Now, we can create a virtual environment and store its tools in the "bhandari" folder .
python3 -m venv bhandari
Note: you can named this "bhandari" folder; anyname you like( Standard practice is to name it "env" ...)
Now to activate your virtual environment, from the directory of your folder, type the following command this will activate our virtual environment in the “bhandari” folder
source bhandari/bin/activate
If you have successfully activated your virtual environment, you should see the (bhandari) word indicating that we are working in a virtual environment.
After this, we can install anything that will be isolated from the rest of the system....
Unable to run the rasa init command and getting following error:
'rasa' is not recognized as an internal or external command, operable program or batch file.
I have following version of RASA in my environment:
rasa-core 0.13.2
rasa-core-sdk 0.12.2
rasa-nlu 0.14.6
rasa-sdk 1.2.0
Sams answer is right. Rasa is probably not in your environment variable path.
Have you already tried:
py -m rasa init
or
python -m rasa init
If this doesn't work you may find answers at the rasa community forum
Did you try pip based installation as mentioned here
You can do
pip install rasa
If you have already done that I suspect that you need to add rasa in the environment variable PATH
Also are you using virtualenv? or conda environment? I would suggest using that to do the installation.
I had this issue with python 3.9. It worked after downgrading the python version to 3.8. It required recreating my conda environment.
Hopefully you got it working by now, but if not you can either
1) Try setting the Python path in Advanced System Settings > Environment Variables. (ideally we want it in a top-level folder)
2) Re-install Python using the graphical installer. Run the regular Python installer as administrator. BE SURE to click the little ‘Add to PATH’ checkbox, or all this will be for naught!! (For me personally this is a lot easier than manually adjusting the path in environment variables.)
Then choose “Custom install location.” Clicking “Install for all users” should automatically change the install path to the C:Program Files folder.
3) You may also be able to do this without a full reinstall by selecting Programs > Programs and Features > Modify/Repair.
Go to Settings -> Manage App Execution Aliases -> Turn Python Off - since I had both Python and Python3 enabled, the VSCODE was not letting me access the virtual environment I created in the Project Folder. This solved my issue.
Wrong Path in cmd Terminal of VSCODE:
C:\User....\Project>rasa --version
'rasa' was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.
Correct Path in cmd Terminal of VSCODE (after turning off Python in Computer App Settings):
(venv) C:\User....\Project>rasa --version
Rasa Version : 2.3.4
Rasa SDK Version : 2.3.1
Rasa X Version : 0.37.1
Python Version : 3.7.10
The accepted answer says to set the environment variables which made me curious but the problem is I do not know the rasa installation path to set the environment variables.
Step 1:
So I'll write down how I figured this out. First, if you don't have the Anaconda package manager install it from the official website. (While installing click the checkbox to add Anaconda to your PATH environment variable.)
Step 2:
Now open up the anaconda prompt and go to the directory where you want to run rasa.
Step 3:
Then we can create a new conda environment by running conda create --name installingrasa python==3.8.5 to keep all of our dependencies together in a centralized place. Finally activate the environment by conda activate installingrasa
Step 4:
Install UJSON and Tensorflow that will help us to work with rasa.
conda install ujson
conda install tensorflow
Step 5:
Ultimately we can install rasa. Here we are going to install it via pip rather than conda. (there is no conda version fr rasa at the moment I'm writing this)
pip install rasa
Step 6:
In order to run Tensorflow on windows, we need to download visual c++ separately. Find the executable from the official website. And now we can run rasa init without errors and initialize new bot.
try this code while creating a virtual environment
conda create --name filename python==3.8
Looks like this is an issue of python 3.9. After playing around a lot with 3.9, I downgraded my python to 3.8 and it worked without a glitch.
You can create a conda environment with a different python version by using the option python==3.8 in the conda create command line.
The above solutions didn't worked for me.
After a lot of searching I found that rasa was located at C:\Users\tejas\AppData\Roaming\Python\Python36\Scripts\rasa.py (installed using pip install rasa)
As I was working anaconda environment named as(RASA)
I didn’t found rasa.py at C:\Users\tejas\anaconda3\envs\RASA\Scripts nor in
C:\Users\tejas\anaconda3\Scripts
So I just copy pasted rasa.py at these 2 locations and it worked for me in anaconda environment.
You might forget to install the rasa package. You can follow the steps to install rasa on your machine.
Create a new virtual environment named venv
You can also install rasa without virtual environment. but it would be better to track the dependencies if we are in a virtual environment.
python3 -m venv venv
Activate the virtual environment
For windows: venv\Scripts\activate
For Ubuntu: source ./venv/bin/activate
Install rasa package
pip3 install -U pip
pip3 install rasa
For more: Rasa installation
Try this command,
pip3 install -U --user pip && pip3 install rasa
It worked for me, This command will upgrade your pip to the latest version, and rasa will be successfully installed, and check it by typing rasa --version.
If it still doesn't work, download the python 3.7 version using miniconda,set the environment using miniconda, and then install rasa using this command again
I was attempting to use anaconda to download tensorflow. I followed the guide character by character. Anaconda downloaded and installed. I used the command:
c:>conda create -n tensorflow python=3.5
which worked, then I used:
c:> activate tensorflow
Which failed to change to a # prompt. So I tried using pip install and got an error message:
'pip' is not recognized as an internal or external command, operable
program or batch file.
Does anyone have any suggestions on how to correct this?
Did you mean to use:
conda create -n tensorflow tensorflow python=3.5
the conda command:
conda install -n <env_name> <package>
translates your code
conda install -n tensorflow pythong-3.5
tells conda to:
- create a new environment,
- that you want your new environment to be named tensorflow, and to
- install python version 3.5 in the environment you just created.
You did not actually tell conda to install TensorFlow.
Personally, I prefer to name my environment, then change into it to install packages:
conda create -n new_env_name python=3.5
source activate new_env_name
conda install tensorflow numpy pandas matplotlib
* Note: if you are on Windows, you may need to use activate my_env_name instead of source activate my_env_name to start your environment.
Which command to use is dependent on what terminal window you are using:
- Powershell requires activate my_env_name,
- Git Bash requires source activate my_env_name.
Often instructions naively state the the former is always used when on a Windows system.
Try source activate tensorflow.
On mac and in some windows environments source activate <env_name> is required. activate <env_name> is used instead in some Windows' environments.
For example, on Windows, if you're in a Git Bash terminal window, you must use source activate <env_name>, but if you're in a Powershell terminal window, then activate <env_name> would be required.
Linux/Mac will always (so far as I know) require source activate <env_name>
Run Anaconda Prompt as an administrator
I just have the same problem and by this way it's fixed.
I am very new to python and plan to use psychopy quite a lot. I am on a work computer but have full admin rights.
Psychopy came with python version 2.7.11 and includes setuptools already.
I am trying to install the selenium module, but having trouble getting pip to work at all.
In cmd, it is recognising the 'python' command, so I know python is in my path.
I get the message "can't open file 'pip': [Errno2] No such file or directory" from:
python pip install selenium
I get " 'pip' is not recognised as an internal or external command" from:
pip install selenium
When I change directory to where pip is located, I get:
Fatal error in launcher: Unable to create process using '"'
Using pip2 makes no difference.
It seems a simple thing but where am I going wrong with this?!
I never really got to the bottom of this, but this is what I found out and here are the commands that worked for me in Windows. Be aware that I am far from expert!
To run python scripts (*.py) from command line (cmd) then C:\PsychoPy2 and C:\PsychoPy2\DLLs need to be in path. ('Path' contains directories or file extensions that can be more globally accessed, i.e. do not require you to change the prompt to the relevant directories first).
To check, open cmd and either type echo %PATH% or just type python. (If python starts, the line will say >>>. You can exit by typing quit())
To add to path, get properties of computer, then advanced system settings, then environment variables.
To check pip.exe (a sort of installation wizard) is installed, either search for the file, or check C:\PsychoPy2\Scripts for it. This may also need to be in path.
To reinstall the latest versions of pip and setup tools, I went to cmd and typed:
python -m pip install -U pip setuptools
If the same code did not work for other modules (which in my case was due to network access), then I downloaded the wheel file (*.whl) for that module (from their website) and ran the following code:
python -m pip install c:/modulename.whl
These may not be the correct ways of doing things, but they worked for me when I couldn't get other ways to work!
I've just had the exact same issue with the pip install, and a conflict with PsychoPy installations. I think it's because python automatically wants to call on the path that's been set by Psychopy, so it can't get to the 'pip' folders that for me, remain in a temporary/hidden file. This wasn't intuitive for me - on any machine without psychopy python just 'works' when you download it.
I've been using Python 2.7.10 in a virtualenv environment for a couple of months.
Yesterday, activating the environment went fine, but today suddently I get this cryptic error when trying to start Python from Terminal:
Illegal instruction: 4
I have made no changes to my environment (AFAIK), so I'm having a difficult time trying to come to terms with what this error is and what caused it.
Python works fine outside of this virtualenv environment. When running via /usr/local/bin it presents no problem.
I've had this problem a number of times now. While I can't say for certain what the actual issue is, I believe it basically means that some file(s) in the virtualenv installment of Python have become corrupted.
I keep my virtual environment in a synced Dropbox folder, so that may be a large contributor to the issue.
Restoring the virtual environment from a back-up archive worked for me. Or simply reinstall an identical virtual environment.
First, try activating the faulty environment by cd <path/to/old_env> and source /bin/activate.
If it's successfully activated, cd to an accessible location on the drive and run pip freeze > requirements.txt to export a list of currently installed Python modules.
Delete the old environment.
Install a new virtual environment of the latest version of Python 2 that you have on the computer, via virtualenv <path/new_env>
Or, if you want to use a specific Python version, first make sure you have you have it on your drive, and then do virtualenv -p <path>. Assuming that you have downloaded the Python version with Homebrew, e.g.: virtualenv -p /usr/local/bin/python2.6 <path/new_env>
Activate the virtual environment via cd <path/new_env> and then do source /bin/activate.
Assuming that you kept a list of modules to reinstall by previously doing pip freeze > requirements.txt, cd to the folder where the text file is located and do pip install -r requirements.txt.
Otherwise, reinstall the modules with pip manually.
I had same problem and found solution by uninstalling psycopg2 and installing older version. As I understood my comp was not supporting some commands in new version