简体   繁体   English

Django没有名为“ psycopg2”的模块

[英]Django No module named 'psycopg2'

Hey I tried find something what resolve my problem but nothing helped me. 嘿,我试图找到解决我问题的方法,但是没有任何帮助。 I'm trying to install 'psycopg2' to using PostreSQL in my project. 我正在尝试在项目中安装“ psycopg2”以使用PostreSQL。

I tried install it using pip, easy_install ect. 我尝试使用pip,easy_install等安装它。 I'm using PyCharm so i tried install it i "install package window" but I'm getting something like this: 我正在使用PyCharm,因此我尝试在“安装包窗口”中安装它,但我得到的是这样的东西:

Collecting psycopg2
  Using cached psycopg2-2.6.1.tar.gz
    Complete output from command python setup.py egg_info:
    running egg_info
    creating pip-egg-info\psycopg2.egg-info
    writing pip-egg-info\psycopg2.egg-info\PKG-INFO
    writing dependency_links to pip-egg-info\psycopg2.egg-info\dependency_links.txt
    writing top-level names to pip-egg-info\psycopg2.egg-info\top_level.txt
    writing manifest file 'pip-egg-info\psycopg2.egg-info\SOURCES.txt'
    warning: manifest_maker: standard file '-c' not found

    Error: pg_config executable not found.

    Please add the directory containing pg_config to the PATH
    or specify the full executable path with the option:

        python setup.py build_ext --pg-config /path/to/pg_config build ...

    or with the pg_config option in 'setup.cfg'.

    ----------------------------------------

Command "python setup.py egg_info" failed with error code 1 in C:\Users\Bartek\AppData\Local\Temp\pycharm-packaging0.tmp\psycopg2\

I'm working on Windows for now, can you give me some advice how resolve this problem? 我现在正在Windows上工作,您能给我一些建议如何解决此问题吗? I'm sitting on it more than 2 hours :( 我坐了两个多小时:(

After install clean PostgreSQL i tried again "pip install psycopg2" and i got: 安装干净的PostgreSQL后,我再次尝试“ pip install psycopg2”,我得到了:

Collecting psycopg2
  Using cached psycopg2-2.6.1.tar.gz
Building wheels for collected packages: psycopg2
  Running setup.py bdist_wheel for psycopg2: started
  Running setup.py bdist_wheel for psycopg2: finished with status 'error'
  Complete output from command C:\Users\Bartek\dJangoEnvironment\Scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Bartek\\AppData\\Local\\Temp\\pycharm-packaging0.tmp\\psycopg2\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d C:\Users\Bartek\AppData\Local\Temp\tmp2ohduth5pip-wheel- --python-tag cp35:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win32-3.5
  creating build\lib.win32-3.5\psycopg2
  copying lib\errorcodes.py -> build\lib.win32-3.5\psycopg2
  copying lib\extensions.py -> build\lib.win32-3.5\psycopg2
  copying lib\extras.py -> build\lib.win32-3.5\psycopg2
  copying lib\pool.py -> build\lib.win32-3.5\psycopg2
  copying lib\psycopg1.py -> build\lib.win32-3.5\psycopg2
  copying lib\tz.py -> build\lib.win32-3.5\psycopg2
  copying lib\_json.py -> build\lib.win32-3.5\psycopg2
  copying lib\_range.py -> build\lib.win32-3.5\psycopg2
  copying lib\__init__.py -> build\lib.win32-3.5\psycopg2
  creating build\lib.win32-3.5\psycopg2\tests
  copying tests\dbapi20.py -> build\lib.win32-3.5\psycopg2\tests
  copying tests\dbapi20_tpc.py -> build\lib.win32-3.5\psycopg2\tests
  copying tests\testconfig.py -> build\lib.win32-3.5\psycopg2\tests
  copying tests\testutils.py -> build\lib.win32-3.5\psycopg2\tests
  copying tests\test_async.py -> build\lib.win32-3.5\psycopg2\tests
  copying tests\test_bugX000.py -> build\lib.win32-3.5\psycopg2\tests
  copying tests\test_bug_gc.py -> build\lib.win32-3.5\psycopg2\tests
  copying tests\test_cancel.py -> build\lib.win32-3.5\psycopg2\tests
  copying tests\test_connection.py -> build\lib.win32-3.5\psycopg2\tests
  copying tests\test_copy.py -> build\lib.win32-3.5\psycopg2\tests
  copying tests\test_cursor.py -> build\lib.win32-3.5\psycopg2\tests
  copying tests\test_dates.py -> build\lib.win32-3.5\psycopg2\tests
  copying tests\test_extras_dictcursor.py -> build\lib.win32-3.5\psycopg2\tests
  copying tests\test_green.py -> build\lib.win32-3.5\psycopg2\tests
  copying tests\test_lobject.py -> build\lib.win32-3.5\psycopg2\tests
  copying tests\test_module.py -> build\lib.win32-3.5\psycopg2\tests
  copying tests\test_notify.py -> build\lib.win32-3.5\psycopg2\tests
  copying tests\test_psycopg2_dbapi20.py -> build\lib.win32-3.5\psycopg2\tests
  copying tests\test_quote.py -> build\lib.win32-3.5\psycopg2\tests
  copying tests\test_transaction.py -> build\lib.win32-3.5\psycopg2\tests
  copying tests\test_types_basic.py -> build\lib.win32-3.5\psycopg2\tests
  copying tests\test_types_extras.py -> build\lib.win32-3.5\psycopg2\tests
  copying tests\test_with.py -> build\lib.win32-3.5\psycopg2\tests
  copying tests\__init__.py -> build\lib.win32-3.5\psycopg2\tests
  Skipping optional fixer: buffer
  Skipping optional fixer: idioms
  Skipping optional fixer: set_literal
  Skipping optional fixer: ws_comma
  warning: build_py: byte-compiling is disabled, skipping.

  running build_ext
  building 'psycopg2._psycopg' extension
  error: Unable to find vcvarsall.bat

  ----------------------------------------
  Running setup.py clean for psycopg2
Failed to build psycopg2
Installing collected packages: psycopg2
  Running setup.py install for psycopg2: started
    Running setup.py install for psycopg2: finished with status 'error'
    Complete output from command C:\Users\Bartek\dJangoEnvironment\Scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Bartek\\AppData\\Local\\Temp\\pycharm-packaging0.tmp\\psycopg2\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record C:\Users\Bartek\AppData\Local\Temp\pip-si2d11i4-record\install-record.txt --single-version-externally-managed --compile --install-headers C:\Users\Bartek\dJangoEnvironment\include\site\python3.5\psycopg2:
    running install
    running build
    running build_py
    creating build
    creating build\lib.win32-3.5
    creating build\lib.win32-3.5\psycopg2
    copying lib\errorcodes.py -> build\lib.win32-3.5\psycopg2
    copying lib\extensions.py -> build\lib.win32-3.5\psycopg2
    copying lib\extras.py -> build\lib.win32-3.5\psycopg2
    copying lib\pool.py -> build\lib.win32-3.5\psycopg2
    copying lib\psycopg1.py -> build\lib.win32-3.5\psycopg2
    copying lib\tz.py -> build\lib.win32-3.5\psycopg2
    copying lib\_json.py -> build\lib.win32-3.5\psycopg2
    copying lib\_range.py -> build\lib.win32-3.5\psycopg2
    copying lib\__init__.py -> build\lib.win32-3.5\psycopg2
    creating build\lib.win32-3.5\psycopg2\tests
    copying tests\dbapi20.py -> build\lib.win32-3.5\psycopg2\tests
    copying tests\dbapi20_tpc.py -> build\lib.win32-3.5\psycopg2\tests
    copying tests\testconfig.py -> build\lib.win32-3.5\psycopg2\tests
    copying tests\testutils.py -> build\lib.win32-3.5\psycopg2\tests
    copying tests\test_async.py -> build\lib.win32-3.5\psycopg2\tests
    copying tests\test_bugX000.py -> build\lib.win32-3.5\psycopg2\tests
    copying tests\test_bug_gc.py -> build\lib.win32-3.5\psycopg2\tests
    copying tests\test_cancel.py -> build\lib.win32-3.5\psycopg2\tests
    copying tests\test_connection.py -> build\lib.win32-3.5\psycopg2\tests
    copying tests\test_copy.py -> build\lib.win32-3.5\psycopg2\tests
    copying tests\test_cursor.py -> build\lib.win32-3.5\psycopg2\tests
    copying tests\test_dates.py -> build\lib.win32-3.5\psycopg2\tests
    copying tests\test_extras_dictcursor.py -> build\lib.win32-3.5\psycopg2\tests
    copying tests\test_green.py -> build\lib.win32-3.5\psycopg2\tests
    copying tests\test_lobject.py -> build\lib.win32-3.5\psycopg2\tests
    copying tests\test_module.py -> build\lib.win32-3.5\psycopg2\tests
    copying tests\test_notify.py -> build\lib.win32-3.5\psycopg2\tests
    copying tests\test_psycopg2_dbapi20.py -> build\lib.win32-3.5\psycopg2\tests
    copying tests\test_quote.py -> build\lib.win32-3.5\psycopg2\tests
    copying tests\test_transaction.py -> build\lib.win32-3.5\psycopg2\tests
    copying tests\test_types_basic.py -> build\lib.win32-3.5\psycopg2\tests
    copying tests\test_types_extras.py -> build\lib.win32-3.5\psycopg2\tests
    copying tests\test_with.py -> build\lib.win32-3.5\psycopg2\tests
    copying tests\__init__.py -> build\lib.win32-3.5\psycopg2\tests
    Skipping optional fixer: buffer
    Skipping optional fixer: idioms
    Skipping optional fixer: set_literal
    Skipping optional fixer: ws_comma
    warning: build_py: byte-compiling is disabled, skipping.

    running build_ext
    building 'psycopg2._psycopg' extension
    error: Unable to find vcvarsall.bat

    ----------------------------------------

  Failed building wheel for psycopg2
Command "C:\Users\Bartek\dJangoEnvironment\Scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Bartek\\AppData\\Local\\Temp\\pycharm-packaging0.tmp\\psycopg2\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record C:\Users\Bartek\AppData\Local\Temp\pip-si2d11i4-record\install-record.txt --single-version-externally-managed --compile --install-headers C:\Users\Bartek\dJangoEnvironment\include\site\python3.5\psycopg2" failed with error code 1 in C:\Users\Bartek\AppData\Local\Temp\pycharm-packaging0.tmp\psycopg2\

Install Postgresql , add C:\\Program Files (x86)\\PostgreSQL\\9.4\\bin\\ to your path and try pip install psycopg2 again. 安装Postgresql ,将C:\\Program Files (x86)\\PostgreSQL\\9.4\\bin\\到您的路径,然后再次尝试pip install psycopg2

Looks like you need to download Visual Studio as well. 看起来您也需要下载Visual Studio

I resolve my problem using: 我使用以下方法解决了我的问题:

http://samudranb.com/2012/06/02/how-to-setup-a-djangopython-development-env-on-windows/ http://samudranb.com/2012/06/02/how-to-setup-a-djangopython-development-env-on-windows/

This is only solution for me. 这只是我的解决方案。 Visual, PostgreSQL doesn't help for this. 视觉,PostgreSQL对此无济于事。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM