29082
Herokuを使っているのですが、`Windows7`にて、

```

    C:\Users\dragonball\heroku\okinta>pip install -r requirements.txt
    
```

をすると、以下のエラーが出てきて、どうしていいか分かりません。どのようにすればいいのかアドバイス頂けないでしょうか？

```

    C:\Users\dragonball\heroku\okinta>pip install -r requirements.txt
    
    Collecting dj-database-url==0.4.0 (from -r requirements.txt (line 1))
    Collecting Django==1.9.2 (from -r requirements.txt (line 2))
      Using cached Django-1.9.2-py2.py3-none-any.whl
    Collecting gunicorn==19.4.5 (from -r requirements.txt (line 3))
      Using cached gunicorn-19.4.5-py2.py3-none-any.whl
    Collecting psycopg2==2.6.1 (from -r requirements.txt (line 4))
      Using cached psycopg2-2.6.1.tar.gz
    Collecting whitenoise==2.0.6 (from -r requirements.txt (line 5))
      Using cached whitenoise-2.0.6-py2.py3-none-any.whl
    Collecting requests==2.9.1 (from -r requirements.txt (line 6))
      Using cached requests-2.9.1-py2.py3-none-any.whl
    Collecting django-debug-toolbar==1.4 (from -r requirements.txt (line 7))
      Using cached django_debug_toolbar-1.4-py2.py3-none-any.whl
    Collecting sqlparse (from django-debug-toolbar==1.4->-r requirements.txt (line 7
    ))
    Building wheels for collected packages: psycopg2
      Running setup.py bdist_wheel for psycopg2 ... error
      Complete output from command c:\users\dragonball\appdata\local\programs\python\pyt
    hon35-32\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\hide
    ry\\AppData\\Local\\Temp\\pip-build-popk09j9\\psycopg2\\setup.py';exec(compile(g
    etattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__,
     'exec'))" bdist_wheel -d C:\Users\dragonball\AppData\Local\Temp\tmpcssofwgzpip-whee
    l- --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
      running build_ext
      building 'psycopg2._psycopg' extension
      creating build\temp.win32-3.5
      creating build\temp.win32-3.5\Release
      creating build\temp.win32-3.5\Release\psycopg
      C:\Program Files\Microsoft Visual Studio 14.0\VC\BIN\cl.exe /c /nologo /Ox /W3
     /GL /DNDEBUG /MD -DPSYCOPG_DEFAULT_PYDATETIME=1 "-DPSYCOPG_VERSION=\"2.6.1 (dt
    dec pq3 ext)\"" -DPG_VERSION_HEX=0x090504 -Ic:\users\dragonball\appdata\local\progra
    ms\python\python35-32\include -Ic:\users\dragonball\appdata\local\programs\python\py
    thon35-32\include -I. -IC:/PROGRA~1/POSTGR~1/9.5/include -IC:/PROGRA~1/POSTGR~1/
    9.5/include/server "-IC:\Program Files\Microsoft Visual Studio 14.0\VC\INCLUDE"
    "-IC:\Program Files\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Fil
    es\Windows Kits\8.1\include\shared" "-IC:\Program Files\Windows Kits\8.1\include
    \um" "-IC:\Program Files\Windows Kits\8.1\include\winrt" /Tcpsycopg\psycopgmodul
    e.c /Fobuild\temp.win32-3.5\Release\psycopg\psycopgmodule.obj
      psycopgmodule.c
      .\psycopg/config.h(134): warning C4005: 'isnan': macro redefinition
      C:\Program Files\Windows Kits\10\include\10.0.10240.0\ucrt\math.h(264): note:
    see previous definition of 'isnan'
      .\psycopg/config.h(138): warning C4005: 'isinf': macro redefinition
      C:\Program Files\Windows Kits\10\include\10.0.10240.0\ucrt\math.h(263): note:
    see previous definition of 'isinf'
      .\psycopg/config.h(150): error C2491: 'round': definition of dllimport functio
    n not allowed
      error: command 'C:\\Program Files\\Microsoft Visual Studio 14.0\\VC\\BIN\\cl.e
    xe' failed with exit status 2
    
      ----------------------------------------
      Failed building wheel for psycopg2
      Running setup.py clean for psycopg2
    Failed to build psycopg2
    Installing collected packages: dj-database-url, Django, gunicorn, psycopg2, whit
    enoise, requests, sqlparse, django-debug-toolbar
      Running setup.py install for psycopg2 ... error
        Complete output from command c:\users\dragonball\appdata\local\programs\python\p
    ython35-32\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\hi
    dery\\AppData\\Local\\Temp\\pip-build-popk09j9\\psycopg2\\setup.py';exec(compile
    (getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file_
    _, 'exec'))" install --record C:\Users\dragonball\AppData\Local\Temp\pip-pls65_zx-re
    cord\install-record.txt --single-version-externally-managed --compile:
        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\test
    s
        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
        running build_ext
        building 'psycopg2._psycopg' extension
        creating build\temp.win32-3.5
        creating build\temp.win32-3.5\Release
        creating build\temp.win32-3.5\Release\psycopg
        C:\Program Files\Microsoft Visual Studio 14.0\VC\BIN\cl.exe /c /nologo /Ox /
    W3 /GL /DNDEBUG /MD -DPSYCOPG_DEFAULT_PYDATETIME=1 "-DPSYCOPG_VERSION=\"2.6.1 (d
    t dec pq3 ext)\"" -DPG_VERSION_HEX=0x090504 -Ic:\users\dragonball\appdata\local\prog
    rams\python\python35-32\include -Ic:\users\dragonball\appdata\local\programs\python\
    python35-32\include -I. -IC:/PROGRA~1/POSTGR~1/9.5/include -IC:/PROGRA~1/POSTGR~
    1/9.5/include/server "-IC:\Program Files\Microsoft Visual Studio 14.0\VC\INCLUDE
    " "-IC:\Program Files\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program F
    iles\Windows Kits\8.1\include\shared" "-IC:\Program Files\Windows Kits\8.1\inclu
    de\um" "-IC:\Program Files\Windows Kits\8.1\include\winrt" /Tcpsycopg\psycopgmod
    ule.c /Fobuild\temp.win32-3.5\Release\psycopg\psycopgmodule.obj
        psycopgmodule.c
        .\psycopg/config.h(134): warning C4005: 'isnan': macro redefinition
        C:\Program Files\Windows Kits\10\include\10.0.10240.0\ucrt\math.h(264): note
    : see previous definition of 'isnan'
        .\psycopg/config.h(138): warning C4005: 'isinf': macro redefinition
        C:\Program Files\Windows Kits\10\include\10.0.10240.0\ucrt\math.h(263): note
    : see previous definition of 'isinf'
        .\psycopg/config.h(150): error C2491: 'round': definition of dllimport funct
    ion not allowed
        error: command 'C:\\Program Files\\Microsoft Visual Studio 14.0\\VC\\BIN\\cl
    .exe' failed with exit status 2
    
        ----------------------------------------
    Exception:
    Traceback (most recent call last):
      File "c:\users\dragonball\appdata\local\programs\python\python35-32\lib\site-packa
    ges\pip\commands\install.py", line 317, in run
        prefix=options.prefix_path,
      File "c:\users\dragonball\appdata\local\programs\python\python35-32\lib\site-packa
    ges\pip\req\req_set.py", line 742, in install
        **kwargs
      File "c:\users\dragonball\appdata\local\programs\python\python35-32\lib\site-packa
    ges\pip\req\req_install.py", line 880, in install
        spinner=spinner,
      File "c:\users\dragonball\appdata\local\programs\python\python35-32\lib\site-packa
    ges\pip\utils\__init__.py", line 718, in call_subprocess
        % (command_desc, proc.returncode, cwd))
    pip.exceptions.InstallationError: Command "c:\users\dragonball\appdata\local\program
    s\python\python35-32\python.exe -u -c "import setuptools, tokenize;__file__='C:\
    \Users\\dragonball\\AppData\\Local\\Temp\\pip-build-popk09j9\\psycopg2\\setup.py';ex
    ec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'
    ), __file__, 'exec'))" install --record C:\Users\dragonball\AppData\Local\Temp\pip-p
    ls65_zx-record\install-record.txt --single-version-externally-managed --compile"
     failed with error code 1 in C:\Users\dragonball\AppData\Local\Temp\pip-build-popk09
    j9\psycopg2\
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "c:\users\dragonball\appdata\local\programs\python\python35-32\lib\site-packa
    ges\pip\basecommand.py", line 215, in main
        status = self.run(options, args)
      File "c:\users\dragonball\appdata\local\programs\python\python35-32\lib\site-packa
    ges\pip\commands\install.py", line 350, in run
        requirement_set.cleanup_files()
      File "c:\users\dragonball\appdata\local\programs\python\python35-32\lib\site-packa
    ges\pip\utils\build.py", line 38, in __exit__
        self.cleanup()
      File "c:\users\dragonball\appdata\local\programs\python\python35-32\lib\site-packa
    ges\pip\utils\build.py", line 42, in cleanup
        rmtree(self.name)
      File "c:\users\dragonball\appdata\local\programs\python\python35-32\lib\site-packa
    ges\pip\_vendor\retrying.py", line 49, in wrapped_f
        return Retrying(*dargs, **dkw).call(f, *args, **kw)
      File "c:\users\dragonball\appdata\local\programs\python\python35-32\lib\site-packa
    ges\pip\_vendor\retrying.py", line 212, in call
        raise attempt.get()
      File "c:\users\dragonball\appdata\local\programs\python\python35-32\lib\site-packa
    ges\pip\_vendor\retrying.py", line 247, in get
        six.reraise(self.value[0], self.value[1], self.value[2])
      File "c:\users\dragonball\appdata\local\programs\python\python35-32\lib\site-packa
    ges\pip\_vendor\six.py", line 686, in reraise
        raise value
      File "c:\users\dragonball\appdata\local\programs\python\python35-32\lib\site-packa
    ges\pip\_vendor\retrying.py", line 200, in call
        attempt = Attempt(fn(*args, **kwargs), attempt_number, False)
      File "c:\users\dragonball\appdata\local\programs\python\python35-32\lib\site-packa
    ges\pip\utils\__init__.py", line 102, in rmtree
        onerror=rmtree_errorhandler)
      File "c:\users\dragonball\appdata\local\programs\python\python35-32\lib\shutil.py"
    , line 488, in rmtree
        return _rmtree_unsafe(path, onerror)
      File "c:\users\dragonball\appdata\local\programs\python\python35-32\lib\shutil.py"
    , line 378, in _rmtree_unsafe
        _rmtree_unsafe(fullname, onerror)
      File "c:\users\dragonball\appdata\local\programs\python\python35-32\lib\shutil.py"
    , line 378, in _rmtree_unsafe
        _rmtree_unsafe(fullname, onerror)
      File "c:\users\dragonball\appdata\local\programs\python\python35-32\lib\shutil.py"
    , line 378, in _rmtree_unsafe
        _rmtree_unsafe(fullname, onerror)
      File "c:\users\dragonball\appdata\local\programs\python\python35-32\lib\shutil.py"
    , line 378, in _rmtree_unsafe
        _rmtree_unsafe(fullname, onerror)
      File "c:\users\dragonball\appdata\local\programs\python\python35-32\lib\shutil.py"
    , line 387, in _rmtree_unsafe
        onerror(os.rmdir, path, sys.exc_info())
      File "c:\users\dragonball\appdata\local\programs\python\python35-32\lib\site-packa
    ges\pip\utils\__init__.py", line 114, in rmtree_errorhandler
        func(path)
    OSError: [WinError 145] ディレクトリが空ではありません。: 'C:\\Users\\dragonball\\Ap
    pData\\Local\\Temp\\pip-build-popk09j9\\Django\\django\\views\\decorators'
    
```

参考として、

```

    C:\Users\dragonball\heroku\okinta>more requirements.txt
    dj-database-url==0.4.0
    Django==1.9.2
    gunicorn==19.4.5
    psycopg2==2.6.1
    whitenoise==2.0.6
    requests==2.9.1
    django-debug-toolbar==1.4
    
    C:\Users\dragonball\heroku\okinta>python -V
    Python 3.5.1
    
    C:\Users\dragonball\heroku\okinta>psql --version
    psql (PostgreSQL) 9.5.4
    
```

よろしくお願いします。
CC BY-SA 3.0
2016-09-23T13:42:39.303
29081
2016-09-23T14:39:53.880
2016-09-23T14:39:53.880
3054
18525
question
python windows postgresql
psycopg2のインストールが、VisualStudioのコンパイルエラーC2491で終了してしまう
Heroku上ではなくてローカルのWindows環境でインストールするときの話ですね？

```

        psycopgmodule.c
        .\psycopg/config.h(134): warning C4005: 'isnan': macro redefinition
        C:\Program Files\Windows Kits\10\include\10.0.10240.0\ucrt\math.h(264): note
    : see previous definition of 'isnan'
        .\psycopg/config.h(138): warning C4005: 'isinf': macro redefinition
        C:\Program Files\Windows Kits\10\include\10.0.10240.0\ucrt\math.h(263): note
    : see previous definition of 'isinf'
        .\psycopg/config.h(150): error C2491: 'round': definition of dllimport funct
    ion not allowed
        error: command 'C:\\Program Files\\Microsoft Visual Studio 14.0\\VC\\BIN\\cl
    .exe' failed with exit status 2
    
```

このあたりのキーワードで検索してみると、VS2015環境で同様のエラーが発生するという報告が見つかりました。psycopg側で用意していた関数・マクロがVSに付属するようになってしまって競合している、という話のようです。

<https://github.com/psycopg/psycopg2/issues/393>

で、この問題は [Psycopg
2.6.2](http://initd.org/psycopg/articles/2016/07/07/psycopg-262-released/)
で修正済みとのことですから、2.6.1から2.6.2に乗り換えるのが手っ取り早いかと思います。
CC BY-SA 3.0
2016-09-23T13:59:08.390
29082
2016-09-23T13:59:08.390
8000
29081
answer