Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error: Unable to find vcvarsall.bat in installing psycopg2 in windows7

Im using Windows 7 for developing Django 1.3.7 using PostgreSQL 9.3 as database. on my settings.py I set DATABASE_ENGINE = 'django.db.backends.postgresql_psycopg2' but when I try to execute python manage.py syncdb I got this error:

C:\Django-Proj\myproj\myproj>python manage.py syncdb
Traceback (most recent call last):
  File "manage.py", line 61, in <module>
    execute_manager(settings)
  File "c:\Python27\lib\site-packages\django\core\management\__init__.py", line
438, in execute_manager
    utility.execute()
  File "c:\Python27\lib\site-packages\django\core\management\__init__.py", line
379, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "c:\Python27\lib\site-packages\django\core\management\__init__.py", line
261, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "c:\Python27\lib\site-packages\django\core\management\__init__.py", line
67, in load_command_class
    module = import_module('%s.management.commands.%s' % (app_name, name))
  File "c:\Python27\lib\site-packages\django\utils\importlib.py", line 35, in im
port_module
    __import__(name)
  File "c:\Python27\lib\site-packages\django\core\management\commands\syncdb.py"
, line 7, in <module>
    from django.core.management.sql import custom_sql_for_model, emit_post_sync_
signal
  File "c:\Python27\lib\site-packages\django\core\management\sql.py", line 6, in
 <module>
    from django.db import models
  File "c:\Python27\lib\site-packages\django\db\__init__.py", line 78, in <modul
e>
    connection = connections[DEFAULT_DB_ALIAS]
  File "c:\Python27\lib\site-packages\django\db\utils.py", line 93, in __getitem
__
    backend = load_backend(db['ENGINE'])
  File "c:\Python27\lib\site-packages\django\db\utils.py", line 33, in load_back
end
    return import_module('.base', backend_name)
  File "c:\Python27\lib\site-packages\django\utils\importlib.py", line 35, in im
port_module
    __import__(name)
  File "c:\Python27\lib\site-packages\django\db\backends\postgresql_psycopg2\bas
e.py", line 24, in <module>
    raise ImproperlyConfigured("Error loading psycopg2 module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: No m
odule named psycopg2

Then I try to install psycopg2 but it got an error:

C:\>pip install psycopg2
Downloading/unpacking psycopg2
  Running setup.py (path:c:\users\samuel\appdata\local\temp\pip_build_Samuel\psy
copg2\setup.py) egg_info for package psycopg2

Installing collected packages: psycopg2
  Running setup.py install for psycopg2
    building 'psycopg2._psycopg' extension
    error: Unable to find vcvarsall.bat
    Complete output from command C:\Python27\python.exe -c "import setuptools, t
okenize;__file__='c:\\users\\samuel\\appdata\\local\\temp\\pip_build_Samuel\\psy
copg2\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().r
eplace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\samuel\appda
ta\local\temp\pip-dsnjrg-record\install-record.txt --single-version-externally-m
anaged --compile:
    running install

running build

running build_py

creating build

creating build\lib.win-amd64-2.7

creating build\lib.win-amd64-2.7\psycopg2

copying lib\errorcodes.py -> build\lib.win-amd64-2.7\psycopg2

copying lib\extensions.py -> build\lib.win-amd64-2.7\psycopg2

copying lib\extras.py -> build\lib.win-amd64-2.7\psycopg2

copying lib\pool.py -> build\lib.win-amd64-2.7\psycopg2

copying lib\psycopg1.py -> build\lib.win-amd64-2.7\psycopg2

copying lib\tz.py -> build\lib.win-amd64-2.7\psycopg2

copying lib\_json.py -> build\lib.win-amd64-2.7\psycopg2

copying lib\_range.py -> build\lib.win-amd64-2.7\psycopg2

copying lib\__init__.py -> build\lib.win-amd64-2.7\psycopg2

creating build\lib.win-amd64-2.7\psycopg2\tests

copying tests\dbapi20.py -> build\lib.win-amd64-2.7\psycopg2\tests

copying tests\dbapi20_tpc.py -> build\lib.win-amd64-2.7\psycopg2\tests

copying tests\testconfig.py -> build\lib.win-amd64-2.7\psycopg2\tests

copying tests\testutils.py -> build\lib.win-amd64-2.7\psycopg2\tests

copying tests\test_async.py -> build\lib.win-amd64-2.7\psycopg2\tests

copying tests\test_bugX000.py -> build\lib.win-amd64-2.7\psycopg2\tests

copying tests\test_bug_gc.py -> build\lib.win-amd64-2.7\psycopg2\tests

copying tests\test_cancel.py -> build\lib.win-amd64-2.7\psycopg2\tests

copying tests\test_connection.py -> build\lib.win-amd64-2.7\psycopg2\tests

copying tests\test_copy.py -> build\lib.win-amd64-2.7\psycopg2\tests

copying tests\test_cursor.py -> build\lib.win-amd64-2.7\psycopg2\tests

copying tests\test_dates.py -> build\lib.win-amd64-2.7\psycopg2\tests

copying tests\test_extras_dictcursor.py -> build\lib.win-amd64-2.7\psycopg2\test
s

copying tests\test_green.py -> build\lib.win-amd64-2.7\psycopg2\tests

copying tests\test_lobject.py -> build\lib.win-amd64-2.7\psycopg2\tests

copying tests\test_module.py -> build\lib.win-amd64-2.7\psycopg2\tests

copying tests\test_notify.py -> build\lib.win-amd64-2.7\psycopg2\tests

copying tests\test_psycopg2_dbapi20.py -> build\lib.win-amd64-2.7\psycopg2\tests


copying tests\test_quote.py -> build\lib.win-amd64-2.7\psycopg2\tests

copying tests\test_transaction.py -> build\lib.win-amd64-2.7\psycopg2\tests

copying tests\test_types_basic.py -> build\lib.win-amd64-2.7\psycopg2\tests

copying tests\test_types_extras.py -> build\lib.win-amd64-2.7\psycopg2\tests

copying tests\test_with.py -> build\lib.win-amd64-2.7\psycopg2\tests

copying tests\__init__.py -> build\lib.win-amd64-2.7\psycopg2\tests

running build_ext

building 'psycopg2._psycopg' extension

error: Unable to find vcvarsall.bat

----------------------------------------
Cleaning up...
Command C:\Python27\python.exe -c "import setuptools, tokenize;__file__='c:\\use
rs\\samuel\\appdata\\local\\temp\\pip_build_Samuel\\psycopg2\\setup.py';exec(com
pile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __f
ile__, 'exec'))" install --record c:\users\samuel\appdata\local\temp\pip-dsnjrg-
record\install-record.txt --single-version-externally-managed --compile failed w
ith error code 1 in c:\users\samuel\appdata\local\temp\pip_build_Samuel\psycopg2

Storing debug log for failure in C:\Users\Samuel\pip\pip.log

Does anyone have an idea about my case? thanks in advance

like image 231
gadss Avatar asked Jan 12 '14 11:01

gadss


2 Answers

There is the huge list of Unofficial Windows Binaries for Python Extension Packages which are extremely useful for Windows users.

http://www.lfd.uci.edu/~gohlke/pythonlibs/#psycopg

Go to the link, download and install it and you are good to go.

Cheers !

like image 52
ajknzhol Avatar answered Oct 12 '22 13:10

ajknzhol


Don't try to compile psycopg2 for Windows. You'll need a Visual Studio install or Windows SDK and all sorts of other mess.

Just grab a binary build: http://initd.org/psycopg/download/

like image 31
Craig Ringer Avatar answered Oct 12 '22 12:10

Craig Ringer