Issue with virtualenv - cannot activate
I created a virtualenv around my project, but when I try to activate it I cannot. It might just be syntax or folder location, but I am stumped right now.
You can see below, I create the virtualenv and call it venv. Everything looks good, then I try to activate it by running source venv/bin/activate
I'm thinking it might just have to do with my system path, but not sure what to point it to (I do know how to edit the path). I'm on python 7 / windows os, virtual env 2.2.x
Processing dependencies for virtualenv Finished processing dependencies for virtualenv c:\testdjangoproj\mysite>virtualenv --no-site-packages venv The --no-site-packages flag is deprecated; it is now the default behavior. Using real prefix 'C:\\Program Files (x86)\\Python' New python executable in venv\Scripts\python.exe File venv\Lib\distutils\distutils.cfg exists with different content; not overwri ting Installing setuptools.................done. Installing pip...................done. c:\testdjangoproj\mysite>source venv/bin/activate 'source' is not recognized as an internal or external command, operable program or batch file. c:\testdjangoproj\mysite>source venv/bin/activate 'source' is not recognized as an internal or external command, operable program or batch file. c:\testdjangoproj\mysite>source mysite/bin/activate 'source' is not recognized as an internal or external command, operable program or batch file. c:\testdjangoproj\mysite>
source
is a shell command designed for users running on Linux (or any Posix, but whatever, not Windows).
On Windows, virtualenv creates a .bat/.ps1 file, so you should run venv\Scripts\activate
instead (per the virtualenv documentation on the activate script).
Just run activate
, without an extension, so the right file will get used regardless of whether you're using cmd.exe or PowerShell.
I was also facing the same issue in my Windows 10 machine. What steps i tried were:
Go to andconda terminal Step 1
pip3 install -U pip virtualenv
Step 2
virtualenv --system-site-packages -p python ./venv
or
virtualenv --system-site-packages -p python3 ./venv
Step 3
.\venv\Scripts\activate
You can check it via spider tool in anaconda by typing import tensorflow as tf
I had the same problem. I was using Python 2, Windows 10 and Git Bash. Turns out in Git Bash you need to use:
source venv/Scripts/activate
For activation you can go to the
venv
your virtualenv directory bycd venv
.Then on Windows, type
dir
(on unix, typels
). You will get 5 foldersinclude
,Lib
,Scripts
,tcl
and 60Now type
.\Scripts\activate
to activate your virtualenvvenv
.
Your prompt will change to indicate that you are now operating within the virtual environment. It will look something like this (venv)user@host:~/venv$
.
And your venv
is activated now.