Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python django - no module psycopg2.extension even after installing compiled version psycopg2-2.4.5.win32-py2.7.‌exe

I am using python django on windows,and trying to deploy to heroku . When i tried to install psycopg2 using pip,

     pip install psycopg2 

i got error :
unable to find vcvarsall.bat
Then i found that i need to install visual studio 2008 (or) i can directly download and install compiled version , so downlaoded from this link :
http://www.lfd.uci.edu/~gohlke/pythonlibs/
Filename i downloaded : psycopg2-2.4.5.win32-py2.7.‌exe
Even after installing this i am getting error : no module named psycopg2.extensions

So, what more should i do ?

            D:\mycode\python\mysite>heroku run python manage.py syncdb
            Running python manage.py syncdb attached to terminal... up, run.1
            Traceback (most recent call last):
              File "manage.py", line 10, in <module>
                execute_from_command_line(sys.argv)
              File "/app/.heroku/venv/lib/python2.7/site-                                packages/django/core/management/__i
            nit__.py", line 443, in execute_from_command_line
                utility.execute()
              File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/__i
            nit__.py", line 382, in execute
                self.fetch_command(subcommand).run_from_argv(self.argv)
              File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/__i
            nit__.py", line 261, in fetch_command
                klass = load_command_class(app_name, subcommand)
              File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/__i
            nit__.py", line 69, in load_command_class
                module = import_module('%s.management.commands.%s' % (app_name, name))
              File "/app/.heroku/venv/lib/python2.7/site-packages/django/utils/importlib.py"
            , line 35, in import_module
                __import__(name)
              File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", line 8, in <module>
                from django.core.management.sql import custom_sql_for_model,                 emit_post_sync_
            signal
                              File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/sql
            .py", line 6, in <module>
                from django.db import models
              File "/app/.heroku/venv/lib/python2.7/site-                packages/django/db/__init__.py", line 40, in <module>
                backend = load_backend(connection.settings_dict['ENGINE'])
              File "/app/.heroku/venv/lib/python2.7/site-packages/django/db/__init__.py", line 34, in __getattr__
                return getattr(connections[DEFAULT_DB_ALIAS], item)
              File "/app/.heroku/venv/lib/python2.7/site-packages/django/db/utils.py", line92, in __getitem__
backend = load_backend(db['ENGINE'])
              File "/app/.heroku/venv/lib/python2.7/site-packages/django/db/utils.py", line24, in load_backend
                return import_module('.base', backend_name)
              File "/app/.heroku/venv/lib/python2.7/site-packages/django/utils/importlib.py"
            , line 35, in import_module
                __import__(name)
              File "/app/.heroku/venv/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py", line 13, in <module>
                from django.db.backends.postgresql_psycopg2.creation import DatabaseCreation

              File "/app/.heroku/venv/lib/python2.7/site-                                packages/django/db/backends/postgre
            sql_psycopg2/creation.py", line 1, in <module>
                import psycopg2.extensions
            ImportError: No module named psycopg2.extensions

            D:\mycode\python\mysite>                            

While isntalling psycopg2 both by pip and easy_install, installdidnt work as i got this error : unable to find vcvarsall.bat with some msg : no previsouly included directores matching 'doc\src_build'

Thanks

like image 220
ramesh kumar Avatar asked May 02 '12 04:05

ramesh kumar


1 Answers

Despite some claims on the Internet, psycopg2 DOES work in a VirtualEnv.

Download the correct version of win-psycopg2. Typically I use 32-bit Python 2.7 so I got psycopg2-2.4.5.win32-py2.7-pg9.1.3-release.exe.

You CANNOT install this file into a VirtualEnv, but you can rename the .exe file to .zip and open with a utility like 7-Zip. You will get a folder called “psycopg2″ and a file called “psycopg2-2.4.5-py2.7.egg-info”. Copy these into:

[...]\Envs\MyVirtualEnv\Lib\site-packages

This worked for me, hope it works for you.

like image 190
ColdCold Avatar answered Oct 05 '22 22:10

ColdCold