在Windows中为Python 3.4-Django 1.7创建虚拟环境,并安装了其他版本的Python [英] create virtual environment for Python 3.4-Django 1.7 in Windows with another vers of Python installed
问题描述
我是Web编程的新手,因此仅从Python和Django开始.我正在Windows 7上工作,并且已经为我正在处理的项目安装了Python 2.7和Django 1.6.5.
I am new in web programming, so just starting with Python and Django. I am working on Windows 7 and already have Python 2.7 and Django 1.6.5 for a project I am working on.
对于另一个项目,我需要一个具有Python 3.4和Django 1.7的虚拟环境,所以我做到了:
For another project I need a virtual environment with Python 3.4 and Django 1.7 so I did:
- 在另一个文件夹(c:\ python34)中安装Python 3.4
-
为我的新项目(my_proj)创建一个文件夹,并在此处执行:
- install Python 3.4 in another folder (c:\python34)
create a folder for my new project (my_proj) and here executed:
> c:\ python34 \ python -m venv py34env
> c:\python34\python -m venv py34env
> py34env/bin/activate
> py34env/bin/activate
> django-admin.py startproject --template ='my proj github archive'env my_proj
> django-admin.py startproject --template='my proj github archive' env my_proj
> cd my_proj
> cd my_proj
> pip install -r requirements.txt
> pip install -r requirements.txt
> cd src
> python manage.py migration
> python manage.py migrate
Requirements.txt文件包含其他软件包Django 1.7
The file requirements.txt contains among other packages Django 1.7
现在,命令manage.py migration会出现错误:似乎找不到Django.如果执行django --version,则不会得到任何结果,但是如果进行pip冻结,则会显示Django 1.7.
Now command manage.py migrate gives an error: it seems it doesn't find Django. If I do django --version I get no result, but if I do pip freeze it shows me Django 1.7.
任何帮助都将不胜感激,非常感谢,丹妮
Any help will be apreciated, Thanks a lot, Dani
推荐答案
在Windows上使用Python时,我总是安装virtualenvwrapper-win: https://github.com/davidmarble/virtualenvwrapper-win 获得与Linux或OS X上相同的所有便捷命令.
When working with Python on Windows, I always install virtualenvwrapper-win: https://github.com/davidmarble/virtualenvwrapper-win to get all the same convenience commands that you have on Linux or OS X.
您可以使用-p选项(--python的缩写)并指定Python可执行文件的路径,为Python 3.4或任何其他Python运行时创建virutalenv.
You can create a virutalenv for Python 3.4, or any other Python runtime using the -p option (short for --python) and specifying the path to the Python executable:
mkvirtualenv my_env -p C:\python34\python.exe
这篇关于在Windows中为Python 3.4-Django 1.7创建虚拟环境,并安装了其他版本的Python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!