I installed python on Windows and build a virtual environment. The first virtual environment is working. But when i try to run a second virtual environment it creates the environment as the first one but when i try to "activate" the second one,
.\newenv\Scripts\activate
(activate.ps1 is neither working)
it answers:
you must 'source' this script: PS> . .\newenv\Scripts\activate
Of curse, there is no "source" command on Windows 7 Powershell. What seems obscure to me is that the first virtual environment was running at the first try, so i though there would be no problems, but it seems as if it seems to lack something.
please install virtualenv in the Scripts folder of your new environment and activate it by using name
activate newvenv
I found the answer in Activating new python environment on Windows 7
The only way it worked for me was the creation of the environment with this command:
python -m venv py34env
After that, I was able to activate the new environment with:
py23env\Scripts\activate
I donĀ“t know what the reason for this behavior is, i guess that Windows 7 is not much in use so this problem was simply not discovered yet(?)
Related
I created a new virtual environment by using Ubuntu windows version. Here you can see from photos,
But in Pycharm, it does not shown as python interpreter.
There is no file in bin folder. I have to select Python from there but i could not figure it out.
I tried to deactivate my virtual environment : sses and try again from pycharm but still not working.
Thank you for your comments from now.
I downloaded Pycharm Pro version. It has a WHL option in interpreters. Solved. Thanks for the responses :)
(a solution relevant to the title but not the question)
To be able to use virtual environment in PyCharm, you must have virtualenv installed on your system. Otherwise, PyCharm will tell you that it could not find '/bin/python'.
In Ubuntu, installing virtual environment is as simple as
sudo apt install python3-virtualenv
Not sure what is wrong with your env, but python "now" comes with their own embedded virtual environment.
https://docs.python.org/3/library/venv.html
You can use it with python -m venv <path>, and activate with <path>/bin/activate.
try adding environment variables to path or try reinstalling python.
I've been told that to activate a Virtual Environment in Django for Windows I should try:
environment_path\Scripts\activate
But when I enter that, cmd returns this error:
The system cannot find the path specified.
I created the virtual environment by entering:
python3 -m venv env
However when I try env\Scripts\activate I get the error described.
Can anyone help? Thanks.
Activating a virtual environment on Windows depends on where you are running it from. From the Windows Command Prompt, the command is:
environment_path\Scripts\activate.bat
If the Git-Bash shell is being used, which adds several useful tools and a more Unix/Linux-like environment, then the command is:
source environment_path\Scripts\activate
I have found the prerequisites section of Test-Driven Development with Python aka "the Testing Goat book" to be handy in getting Django, Python and related things setup on Windows.
You can create virtual environment in windows as:
py -m venv myenv (Here myenv is the name that users give. It can be anything you want)
Now to activate your myenv virtual environment type:myenv\scripts\activate
To deactivate virtual environment simply type:
deactivate
If you are using windows 7, then try environment_path\Scripts\activate.ps1
Also, error is saying, The system cannot find the path specified., make sure your path is correct.
Remember scripts folder is in your virtualenv folder.
The interpreter I use is
and it works in virtual environment. I have both anaconda and python interpreter installed in my system
But if I want to install something using pip for instance "Flask" then it happens
I am using Linux Mint 18.1 Serena"
And the way I tried to create the virtual environment is
Lastly there is no space in the directories where I tried to create virtual environment
Then I tried this link
Specifically the following commands
All those things didn't solve my problem and lastly I ended with the following errors each time I open my shell
Then I change my source of bashrc & bashrc-org to
virtualenv
export WORKON_HOME=~/virtualenvs
source /home/cryptosilicon/anaconda3/bin/python
Now get the following error
How do I correct the error and make the pip work inside virtual environment ?
I just solved (or at least found a work-around) for a similar problem.
I am using Linux Mint 18 and python 3.
I was trying to install a dependency inside a Python virtual environment using pip and it would fail (and actually pretty much mess up my whole virtual env).
The message was : "bad interpreter: No such file or directory".
But I noticed that the referenced path was actually truncated at the first space.
So I tested an virtual env in a folder for which path there is no space and it worked.
Following Tyler Butler's post, I was able to install pip, python and virtualenv to my PowerShell. However, I can only enter a virtual environment where I have created it. If I open a new session of Power Shell, workon can only show me the the first virtual environment I that have ever created.
The initial loading of the first virtual environment
Unable to load the existing virtual environment. After specifying workon venv, nothing gets loaded
Unable to create the virtual environment under the same name, thus some thing has been in place.
After creating several more virtual environment, the workon command can only get me back venv as existing virtual environment.
Seeking help with getting the virtual environment function working in PowerSheel.
Original answer
Thanks to the suggestions from: http://www.voidynullness.net/blog/2014/06/19/install-python-setuptools-pip-virtualenvwrapper-for-powershell-pyside-on-windows/
Including the following specification to the File ~\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1, where ~ stands for the root folder of the user.
Import-Module virtualenvwrapper
As of now, in the new sessions of the PowerShell, workon functions nicely.
Better alternative in 2018: Unix on Windows
Comment from 2018-11-26: please follow this guide and use the Windows Subsystem for Linux instead.
The "subsystem" can freely access everything that exists in the Windows OS (e.g. use /mnt/c/users/your-username to visit the home directory), and I have been writing to the same project folder using both WSL terminals and Gvim on Windows with no problem (concern here maybe the LF vs CRLF conversion).
Working in Windows PowerShell, I created a virtual environment within Anaconda using
>create conda -n test python=2.7.8
I activated it using
>activate test
activating environment "test"...
The test env contains no packages. Python is the only thing in there. I checked the test\Lib\site-packages folder and it is empty.
I started python
>python
>>>import pandas
>>>pandas.Series(range(1,5))
0 1
1 2
2 3
3 4
dtype: int64
I expected error messages because there is no pandas installed in this virtual env. Instead it seems to be importing pandas from the global Anaconda environment, where pandas is installed.
I thought virtual environments were supposed to be isolated. Have I misunderstood how they are supposed to work?
If they are supposed to be isolated, what might the problem be?
New to stack overflow, but I think I can help. First, the commands I needed to run were a bit different (I am on Linux). That is, in fact, how virtual environments are supposed to work. A few things to try: conda create --dry-run -n test python=2.7.8 to see if pandas is being installed to the venv (I don't know why it would). Another idea, when you activate test does the prompt actually change to the venv? Maybe see: virtualenv-in-powershell
Windows has a little idiosyncrasy that can lead to confusing situations like this, which is that it always implicitly puts . (the current directory) in the front of the search PATH. This means that if you are currently in the Anaconda directory when you start python, it will run the python.exe in that directory, regardless of what the rest of your PATH looks like (the activate command, in case you don't know, works by modifying the order of directories in the PATH variable).
The solution is to cd away from the Anaconda directory before starting Python.