10

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

6
  • ya..psycopg2.extensions...editing the above question also.. it is in command prompt, so i cant copy paste the whole thing from command prompt May 2, 2012 at 5:32
  • i also read that, we need to do this before doing "pip install psycopg2" -- > sudo apt-get intall python-dev postgresql-server-all , but i cant use apt-get command as i am using windows . But i tried installing win-get from sourceforge , using that gave visual studio debugging error May 2, 2012 at 5:35
  • do u mean , postgresql 9.1.3, i installed it. May 2, 2012 at 6:11
  • then wat should i download ? one website i used : lfd.uci.edu/~gohlke/pythonlibs <br> This also i used : stickpeople.com/projects/python/win-psycopg May 2, 2012 at 6:26
  • forgot to tell, while installing psycopg2, i got error "unable to find vcvarsall.bat" with another msg : no previously included directories found matching 'doc\src_build' May 2, 2012 at 6:56

4 Answers 4

14

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.

1
0

Take a look at http://slacy.com/blog/2010/09/python-unable-to-find-vcvarsall-bat/. It seems you need to install Microsoft Visual Studio Express to solve the vcvarsall.bat issue. Pretty crazy...

0

Binaries from this link: http://www.stickpeople.com/projects/python/win-psycopg/

In settings.py it should look like this in db settings

    'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
3
  • i have tried that binary also , and i did editing that ENGINE already , but still that "no module error " May 2, 2012 at 5:39
  • got answer friends, will post soon May 2, 2012 at 8:29
  • I'm having the same issue. What did you do to fix this? May 3, 2012 at 19:35
0

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

Yes, this work!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.