2014-02-19 100 views
0

我對Python,Django和Heroku相對比較陌生。我試圖按照關於設置Django Heroku項目的說明找到here。我越來越被困在下面的命令:無法用python virtualenv安裝django-toolkit

$ pip install django-toolbelt 

我收到以下錯誤

Requirement already satisfied (use --upgrade to upgrade): django-toolbelt in c:\ 
django\contactmanager\venv\lib\site-packages 
Requirement already satisfied (use --upgrade to upgrade): django in c:\django\co 
ntactmanager\venv\lib\site-packages (from django-toolbelt) 
Downloading/unpacking psycopg2 (from django-toolbelt) 
    Running setup.py egg_info for package psycopg2 

Downloading/unpacking gunicorn (from django-toolbelt) 
    Running setup.py egg_info for package gunicorn 

    warning: no previously-included files matching '*.pyc' found under directory 
'docs' 
    warning: no previously-included files matching '*.pyo' found under directory 
'docs' 
    warning: no previously-included files matching '*.pyc' found under directory 
'tests' 
    warning: no previously-included files matching '*.pyo' found under directory 
'tests' 
    warning: no previously-included files matching '*.pyc' found under directory 
'examples' 
    warning: no previously-included files matching '*.pyo' found under directory 
'examples' 
Downloading/unpacking dj-database-url (from django-toolbelt) 
    Running setup.py egg_info for package dj-database-url 

Downloading/unpacking dj-static (from django-toolbelt) 
    Running setup.py egg_info for package dj-static 

Downloading/unpacking static (from dj-static->django-toolbelt) 
    Running setup.py egg_info for package static 

Downloading/unpacking pystache (from static->dj-static->django-toolbelt) 
    Running setup.py egg_info for package pystache 
    pystache: using: version '0.6' of <module 'setuptools' from 'C:\Django\conta 
ctmanager\venv\lib\site-packages\distribute-0.6.34-py2.7.egg\setuptools\__init__ 
.pyc'> 

Installing collected packages: psycopg2, gunicorn, dj-database-url, dj-static, s 
tatic, pystache 
    Running setup.py install for psycopg2 
    building 'psycopg2._psycopg' extension 
    Traceback (most recent call last): 
     File "<string>", line 1, in <module> 
     File "C:\Django\contactmanager\venv\build\psycopg2\setup.py", line 568, in 
<module> 
     ext_modules=ext) 
     File "C:\Python27\Lib\distutils\core.py", line 152, in setup 
     dist.run_commands() 
     File "C:\Python27\Lib\distutils\dist.py", line 953, in run_commands 
     self.run_command(cmd) 
     File "C:\Python27\Lib\distutils\dist.py", line 972, in run_command 
     cmd_obj.run() 
     File "C:\Django\contactmanager\venv\lib\site-packages\distribute-0.6.34-py 
2.7.egg\setuptools\command\install.py", line 53, in run 
     return _install.run(self) 
     File "C:\Python27\Lib\distutils\command\install.py", line 563, in run 
     self.run_command('build') 
     File "C:\Python27\Lib\distutils\cmd.py", line 326, in run_command 
     self.distribution.run_command(command) 
     File "C:\Python27\Lib\distutils\dist.py", line 972, in run_command 
     cmd_obj.run() 
     File "C:\Python27\Lib\distutils\command\build.py", line 127, in run 
     self.run_command(cmd_name) 
     File "C:\Python27\Lib\distutils\cmd.py", line 326, in run_command 
     self.distribution.run_command(command) 
     File "C:\Python27\Lib\distutils\dist.py", line 972, in run_command 
     cmd_obj.run() 
     File "C:\Python27\Lib\distutils\command\build_ext.py", line 337, in run 
     self.build_extensions() 
     File "C:\Python27\Lib\distutils\command\build_ext.py", line 446, in build_ 
extensions 
     self.build_extension(ext) 
     File "C:\Django\contactmanager\venv\build\psycopg2\setup.py", line 284, in 
build_extension 
     build_ext.build_extension(self, extension) 
     File "C:\Python27\Lib\distutils\command\build_ext.py", line 496, in build_ 
extension 
     depends=ext.depends) 
     File "C:\Python27\Lib\distutils\msvc9compiler.py", line 473, in compile 
     self.initialize() 
     File "C:\Python27\Lib\distutils\msvc9compiler.py", line 383, in initialize 

     vc_env = query_vcvarsall(VERSION, plat_spec) 
     File "C:\Python27\Lib\distutils\msvc9compiler.py", line 299, in query_vcva 
rsall 
     raise ValueError(str(list(result.keys()))) 
    ValueError: [u'path'] 
    Complete output from command C:\Django\contactmanager\venv\Scripts\python.ex 
e -c "import setuptools;__file__='C:\\Django\\contactmanager\\venv\\build\\psyco 
pg2\\setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file_ 
_, 'exec'))" install --record c:\users\hp\appdata\local\temp\pip-ka3mfj-record\i 
nstall-record.txt --single-version-externally-managed --install-headers C:\Djang 
o\contactmanager\venv\include\site\python2.7: 
    running install 

running build 

running build_py 

running build_ext 

building 'psycopg2._psycopg' extension 

Traceback (most recent call last): 

    File "<string>", line 1, in <module> 

    File "C:\Django\contactmanager\venv\build\psycopg2\setup.py", line 568, in <mo 
dule> 

    ext_modules=ext) 

    File "C:\Python27\Lib\distutils\core.py", line 152, in setup 

    dist.run_commands() 

    File "C:\Python27\Lib\distutils\dist.py", line 953, in run_commands 

    self.run_command(cmd) 

    File "C:\Python27\Lib\distutils\dist.py", line 972, in run_command 

    cmd_obj.run() 

    File "C:\Django\contactmanager\venv\lib\site-packages\distribute-0.6.34-py2.7. 
egg\setuptools\command\install.py", line 53, in run 

    return _install.run(self) 

    File "C:\Python27\Lib\distutils\command\install.py", line 563, in run 

    self.run_command('build') 

    File "C:\Python27\Lib\distutils\cmd.py", line 326, in run_command 

    self.distribution.run_command(command) 

    File "C:\Python27\Lib\distutils\dist.py", line 972, in run_command 

    cmd_obj.run() 

    File "C:\Python27\Lib\distutils\command\build.py", line 127, in run 

    self.run_command(cmd_name) 

    File "C:\Python27\Lib\distutils\cmd.py", line 326, in run_command 

    self.distribution.run_command(command) 

    File "C:\Python27\Lib\distutils\dist.py", line 972, in run_command 

    cmd_obj.run() 

    File "C:\Python27\Lib\distutils\command\build_ext.py", line 337, in run 

    self.build_extensions() 

    File "C:\Python27\Lib\distutils\command\build_ext.py", line 446, in build_exte 
nsions 

    self.build_extension(ext) 

    File "C:\Django\contactmanager\venv\build\psycopg2\setup.py", line 284, in bui 
ld_extension 

    build_ext.build_extension(self, extension) 

    File "C:\Python27\Lib\distutils\command\build_ext.py", line 496, in build_exte 
nsion 

    depends=ext.depends) 

    File "C:\Python27\Lib\distutils\msvc9compiler.py", line 473, in compile 

    self.initialize() 

    File "C:\Python27\Lib\distutils\msvc9compiler.py", line 383, in initialize 

    vc_env = query_vcvarsall(VERSION, plat_spec) 

    File "C:\Python27\Lib\distutils\msvc9compiler.py", line 299, in query_vcvarsal 
l 

    raise ValueError(str(list(result.keys()))) 

ValueError: [u'path'] 

---------------------------------------- 
Command C:\Django\contactmanager\venv\Scripts\python.exe -c "import setuptools;_ 
_file__='C:\\Django\\contactmanager\\venv\\build\\psycopg2\\setup.py';exec(compi 
le(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --re 
cord c:\users\hp\appdata\local\temp\pip-ka3mfj-record\install-record.txt --singl 
e-version-externally-managed --install-headers C:\Django\contactmanager\venv\inc 
lude\site\python2.7 failed with error code 1 in C:\Django\contactmanager\venv\bu 
ild\psycopg2 
Storing complete log in C:\Users\hp\pip\pip.log 

根據這一link我應該python-devpython-psycopg2libpq-dev安裝django-toolbelt之前安裝。

我在一臺Windows機器上。我怎樣才能安裝這些依賴關係?我嘗試用pip安裝它們,但這不起作用。

回答

4

顯然psycopg2安裝程序不能在virtualenv環境下工作。我下載了一個可執行的二進制從http://stickpeople.com/projects/python/win-psycopg/

要在虛擬環境不受安裝本機二進制,使用的easy_install:

C:\virtualenv\Scripts\> activate.bat 
(virtualenv) C:\virtualenv\Scripts\> easy_install psycopg2-2.5.win32-py2.7-pg9.2.4-release.exe