我正在尝试使用以下指南为 Django 1.4 项目创建开发环境:
http://www.stereoplex.com/blog/a-django-development-environment-with-zc-buildout
指南的virtualenv部分运行正常,输出如下:
virtualenv project
New python executable in project\Scripts\python.exe
Installing setuptools................done.
Installing pip...................done.
之后我就可以激活开发环境了。现在我创建名为Source的目录,将bootstrap.py下载到其中并创建一个包含以下内容的buildout.cfg :
[buildout]
parts =
并运行 bootstrap.py 得到以下结果:
Creating directory 'C:\\Dropbox\\XYZ\\project\\Source\\bin'.
Creating directory 'C:\\Dropbox\\XYZ\\project\\Source\\parts'.
Creating directory 'C:\\Dropbox\\XYZ\\project\\Source\\eggs'.
Creating directory 'C:\\Dropbox\\XYZ\\project\\Source\\develop-eggs'.
Generated script 'C:\\Dropbox\\XYZ\\project\\Source\\bin\\buildout'.
问题部分来了 -安装 Django我将 buildout.cfg 配置为以下内容并运行引导程序创建的 bin\buildout:
[buildout]
parts = django
[django]
recipe = djangorecipe
version = 1.4
运行 bin\buildout 后,出现以下错误:
(project) C:\Dropbox\XYZ\project\Source>bin\buildout.exe
Traceback (most recent call last):
File "C:\Dropbox\XYZ\project\Source\bin\buildout-script.py", line 15, in <module> import site # imports custom buildout-generated site.py
File "C:\Dropbox\XYZ\project\Source\parts\buildout\site.py", line 601, in <module> main()
File "C:\Dropbox\XYZ\project\Source\parts\buildout\site.py", line 584, in main known_paths = addsitepackages(known_paths)
File "C:\Dropbox\XYZ\project\Source\parts\buildout\site.py", line 328, in addsitepackages import pkg_resources
ImportError: No module named pkg_resources
虽然如果我直接在项目环境中运行 python,我可以导入 pkg_resources 而不会出错:
(project) C:\Dropbox\XYZ\project\Source>python
Python 2.7.3 (default, Apr 10 2012, 23:24:47) [MSC v.1500 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.
>>> import pkg_resources
>>> pkg_resources
<module 'pkg_resources' from 'C:\Dropbox\XYZ\project\lib\site-packages\setuptools-0.6c11-py2.7.egg\pkg_resources.py'>
我完全被这里打动了。有什么建议么?