Reputation: 21
Trying to set up my Django project to use postgres. I'm on Windows 10, using Python 3.5.1. Used easy_install to install psycopg for Python 3.5 from http://www.stickpeople.com/projects/python/win-psycopg/. I was following the guide at https://djangogirls.gitbooks.io/django-girls-tutorial-extensions/content/optional_postgresql_installation/index.html, but when I got to the part of trying to import psycopg2 to verify a successful installation, I get:
(venv) D:\Projects\webcomic>python -c "import psycopg2"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "D:\Projects\webcomic\venv\lib\site-packages\psycopg2-2.6.1-py3.5-win32.egg\psycopg2\__init__.py", line 50, in <module>
from psycopg2._psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
ImportError: No module named 'psycopg2._psycopg'
Not sure what to do. For what it's worth, my sys.path looks like
>>> pprint(sys.path)
['',
'D:\\Projects\\webcomic\\venv\\lib\\site-packages\\psycopg2-2.6.1-py3.5-win32.egg',
'D:\\Projects\\webcomic\\venv\\Scripts\\python35.zip',
'D:\\Projects\\webcomic\\venv\\DLLs',
'D:\\Projects\\webcomic\\venv\\lib',
'D:\\Projects\\webcomic\\venv\\Scripts',
'c:\\users\\user\\appdata\\local\\programs\\python\\python35-32\\Lib',
'c:\\users\\user\\appdata\\local\\programs\\python\\python35-32\\DLLs',
'D:\\Projects\\webcomic\\venv',
'D:\\Projects\\webcomic\\venv\\lib\\site-packages']
Upvotes: 2
Views: 8407
Reputation: 352
Go to venv/Lib/site-packages
, then delete any psycopg2 related file or folder there, then run this command:
pip install psycopg2
N.B. Make sure venv is still running.
To make sure it is imported correctly, run python manage.py migrate
and it should run without any errors.
Hope I helped!
Upvotes: 3