简体   繁体   中英

Virtualenv installation on OS X

I am trying to install virtualenv on my Mac running OS X Mavericks. To install virtualenv , I used pip

pip install virtualenv

Now when I try to use it, I get the message saying -bash: virtualenv: command not found

Also, an attempt to reinstall gets me this:

Requirement already satisfied (use --upgrade to upgrade): virtualenv in /usr/local/lib/python2.7/site-packages
Cleaning up...

My path and python path variable in the file ~/.bash_profile are set to:

export PATH = /usr/local/bin:$PATH
export PYTHONPATH=/usr/local/lib/python2.7/site-packages

To re-install virtualenv you will first have to uninstall the current version through pip by using the command:

$ pip uninstall virtualenv

From here, it is not all too important that virtualenv is installed under /usr/local/lib/python2.7/site-packages . For example, doing a quick $ which virtualenv shows me that I have mine under:

/Library/Frameworks/Python.framework/Versions/3.3/bin/virtualenv

and I just use $ virtualenv --python=python_version environment_name to select which python version the environment runs.

So, after uninstalling run $ pip install virtualenv again and then check where it is installed using $ which virtualenv

After that you should just be able to create and run your virtual environments straight away using:

Create:

$ virtualenv evnironment_name

Run:

$ source ./environment_name/bin/activate

or cd to the environment directory first and then $ source bin/activate

To exit the environment just run $ deactivate

I hope this helped!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM