Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

virtualenv Env not creating bin directory in Windows 7

I'm a newbie to Python and I've spent hours on this. I can't seem to figure out why when I run a simple command to setup my Python environment: virtualenv --distribute env

This doesn't create a bin file in the env directory.

It only creates:

-- env
   -- Include
   -- Lib
   -- Scripts

My impressions was that a bin directory would be created per a lot of the examples I've found on the web (e.g. I'm not able to run this command: env/bin/activate).

I'm using Windows 7 and Python 2.7.

like image 404
avian Avatar asked Nov 03 '12 07:11

avian


2 Answers

On Windows, this is entirely correct. A bin directory is created on POSIX systems only. From the Windows Notes section of the documentation:

Some paths within the virtualenv are slightly different on Windows: scripts and executables on Windows go in ENV\Scripts\ instead of ENV/bin/ and libraries go in ENV\Lib\ rather than ENV/lib/.

For Windows, run \path\to\env\Scripts\activate to activate the virtualenv. From the documentation again:

On Windows you just do:

> \path\to\env\Scripts\activate

And type deactivate to undo the changes.

Based on your active shell (CMD.exe or Powershell.exe), Windows will use either activate.bat or activate.ps1 (as appropriate) to activate the virtual environment.

like image 154
Martijn Pieters Avatar answered Sep 22 '22 21:09

Martijn Pieters


If you're using Git Bash for Windows, I found the following command works to activate the environment: $ source (path to environment)/Scripts/activate

I was using Git Bash on Windows 10, Python(v3.7), Pip (v19.0.3), virtualenv (v16.4.3)

like image 43
zonian Avatar answered Sep 20 '22 21:09

zonian