我无法在 virtualenv 中启动新项目。这就是我到目前为止所做的:(全新的 Windows 安装)
1)从http://python.org/download/安装python 2.7 (不是64的)
2) 使用 "set path=%path%;C:\python27" 似乎只适用于一个 cmd 会话,所以我添加了 C:\Python27; 在高级系统设置下的我的环境变量中,在 cmd 中键入 python 返回
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32
3) 从http://pypi.python.org/pypi/virtualenv/下载 virtualenv.py运行它:
C:\Users\Maciej\Dropbox\VIRTUALENV_ENVS>python virtualenv.py testenv
New python executable in testenv\Scripts\python.exe
Installing setuptools....................................done.
Installing pip.........................done.
4)激活它并安装一些模块
C:\Users\Maciej\Dropbox\VIRTUALENV_ENVS\testenv\Scripts>activate
(testenv) C:\Users\Maciej\Dropbox\VIRTUALENV_ENVS\testenv\Scripts>
...
(testenv) C:\Users\Maciej\Dropbox\VIRTUALENV_ENVS>pip install -r requirements.txt
...
Successfully installed...
5)测试它是否有效:
testenv) C:\Users\Maciej\Dropbox\VIRTUALENV_ENVS\testenv>python
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> print(django.get_version())
1.4
>>>
6)试图建立一个项目:
(testenv) C:\Users\Maciej\Dropbox\VIRTUALENV_ENVS\testenv>django-admin.py startproject testproject
Traceback (most recent call last):
File "C:\Users\Maciej\Dropbox\VIRTUALENV_ENVS\testenv\Scripts\django-admin.py"
, line 2, in <module>
from django.core import management
ImportError: No module named django.core
来自 virtualenv 的路径:
(testenv) C:\Users\Maciej\Dropbox\VIRTUALENV_ENVS\testenv>python
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print sys.path
['','C:\\Users\\Maciej\\Dropbox\\VIRTUALENV_ENVS\\testenv\\lib\\site-packages\\setuptools-0.6c11-py2.7.egg',
'C:\\Users\\Maciej\\Dropbox\\VIRTUALENV_ENVS\\testenv\\lib\\site-packages\\pip-1.1-py2.7.egg',
'C:\\Windows\\system32\\python27.zip',
'C:\\Users\\Maciej\\Dropbox\\VIRTUALENV_ENVS\\testenv\\DLLs',
'C:\\Users\\Maciej\\Dropbox\\VIRTUALENV_ENVS\\testenv\\lib',
'C:\\Users\\Maciej\\Dropbox\\VIRTUALENV_ENVS\\testenv\\lib\\plat-win',
'C:\\Users\\Maciej\\Dropbox\\VIRTUALENV_ENVS\\testenv\\lib\\lib-tk',
'C:\\Users\\Maciej\\Dropbox\\VIRTUALENV_ENVS\\testenv\\Scripts',
'C:\\Python27\\Lib',
'C:\\Python27\\DLLs',
'C:\\Python27\\Lib\\lib-tk',
'C:\\Users\\Maciej\\Dropbox\\VIRTUALENV_ENVS\\testenv',
'C:\\Users\\Maciej\\Dropbox\\VIRTUALENV_ENVS\\testenv\\lib\\site-packages']
我不知道是什么问题,以及如何解决它,还有另一个问题,来自 c:\python27 的那些文件应该在我的 virtualenv 路径中吗?我应该附上任何其他日志吗?如果是这样戳我。