Skip to content
Advertisement

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:testdjangoprojmysite>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 venvScriptspython.exe
File venvLibdistutilsdistutils.cfg exists with different content; not overwri
ting
Installing setuptools.................done.
Installing pip...................done.

c:testdjangoprojmysite>source venv/bin/activate
'source' is not recognized as an internal or external command,
operable program or batch file.

c:testdjangoprojmysite>source venv/bin/activate
'source' is not recognized as an internal or external command,
operable program or batch file.

c:testdjangoprojmysite>source mysite/bin/activate
'source' is not recognized as an internal or external command,
operable program or batch file.

c:testdjangoprojmysite>

Advertisement

Answer

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 venvScriptsactivate 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.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement