Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python and Virtualenv on Windows

How do you install virtualenv correctly on windows?

I downloaded virtualenv1.9.1 from here and tried installing it with:

python virtualenv.py install

but it does not appear in MyPythonPath/Scripts

I tried the same way installing virutalenvwrapper-win and it installed correctly. But I can't use it because I don't have virtualenv

python.exe: can't open file 'MyPythonPath\Scripts\virtualenv-script.py': [Errno 2 ] No such file or directory

like image 201
tambalolo Avatar asked Jul 19 '13 02:07

tambalolo


People also ask

How do I enable virtualenv in Python?

To install virtualenv, just use pip install virtualenv . To create a virtual environment directory with it, type virtualenv /path/to/directory . Activating and deactivating the virtual environment works the same way as it does for virtual environments in Python 3 (see above).

How do I enable virtual environment in Windows?

Setting up virtualenv This can be done by activating the activate script in the Scripts folder. The following command creates an activate. bat batch file after activation. This creates an activate.

Is virtualenv installed with Python?

Installing virtualenvvenv is included in the Python standard library and requires no additional installation.


3 Answers

The suggested way to install Python packages is to use pip

Please follow this documentation to install pip: https://pip.pypa.io/en/latest/installing/

Note: Python 2.7.9 and above, and Python 3.4 and above include pip already.

Then install virtualenv:

pip install virtualenv
like image 131
woozyking Avatar answered Oct 16 '22 07:10

woozyking


Since I got the same error as mentioned in the question inspite of installing with:

pip install virtualenv

I would like to add a few points, that might also help someone else solve the error in a similar way as me. Don't know if that's the best way, but for me nothing else helped.

Install virtualenv

pip install virtualenv

Move into Scripts directory

cd C:\Python27\Scripts

Create a virtual env.

python virtualenv.exe my_env

Activate the virtual env.

my_env\Scripts\activate.bat

Deactivate the virtual env.

my_env\Scripts\deactivate.bat
like image 12
Susa Avatar answered Oct 16 '22 08:10

Susa


  1. install virtualenv

    pip install virtualenv

  2. create a virtual environment

    python -m virtualenv demoEnv

  3. Activate the environment

    demoEnv\Scripts\activate

  4. To deactivate

    deactivate

like image 4
anubhab Avatar answered Oct 16 '22 09:10

anubhab