问题
I'm trying to install Django and I've created a virtual environment for this project (I'm new in virtualenv). I've created the env this way: virtualenv path which seems to work properly since there is a new folder "env" in my project folder.
Now I tried to install Django into this virtualenv.
\PycharmProjects\Django_tutorial>env/bin/pip install django
'env' is not recognized as an internal or external command, operable program or batch file.
So I've checked the env folder and there are these folders: Include, Lib, Scripts
In the Scripts folder, there is apip.exe so I've decided to try it that way:
\PycharmProjects\Django_tutorial>env/Scripts/pip install django
The same thing occured:
'env' is not recognized as an internal or external command, operable program or batch file.
Do you have any advices how to run this thing correctly?
EDIT: Python 2.7.10 and Windows 8.1
回答1:
You have to activate a your virtual environment first; Check this for how to activate virtual env, https://virtualenv.readthedocs.io/en/latest/user_guide.html
To install pip packages, you just need to call in terminal:
pip install package_name
This will directly install the package to your virtual env.
回答2:
Windows paths use backslashes, as shown in the prompt, not forwards ones.
env\Scripts\pip install django
although I don't know why you should need to use the full path at all; just pip install django should work once the venv is activated.
来源:https://stackoverflow.com/questions/33945808/how-to-use-pip-in-virtualenv