简体   繁体   中英

error comes on writing pip install psycopg2 in windows 10 to connect python with postgres for my django project

I am installing psycopg2 for my Django project to connect with Postgres but got the following error:

When I run this:

pip install psycopg2

On Windows, I got this error:

C:\Users\Aman>pip install psycopg2 Collecting psycopg2 Using cached psycopg2-2.8.5.tar.gz (380 kB) Using legacy setup.py install for psycopg2, since package 'wheel' is not installed. Installing collected packages: psycopg2 Running setup.py install for psycopg2 ... error ERROR: Command errored out with exit status 1: command: 'c:\users\aman\appdata\local\programs\python\python39\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Aman\\AppData\\Local\\Temp\\pip-install-8u0ripm3\\psycopg2\\setup.py'"'"'; __file__='"'"'C:\\Users\\Aman\\AppData\\Local\\Temp\\pip-install-8u0ripm3\\psycopg2\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\Aman\AppData\Local\Temp\pip-record-dasbftyv\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\aman\appdata\local\programs\python\python39\Include\psycopg2' cwd: C:\Users\Aman\AppData\Local\Temp\pip-install-8u0ripm3\psycopg2\ Complete output (22 lines): running install running build running build_py creating build creating build\lib.win-amd64-3.9 creating build\lib.win-amd64-3.9\psycopg2 copying lib\compat.py -> build\lib.win-amd64-3.9\psycopg2 copying lib\errorcodes.py -> build\lib.win-amd64-3.9\psycopg2 copying lib\errors.py -> build\lib.win-amd64-3.9\psycopg2 copying lib\extensions.py -> build\lib.win-amd64-3.9\psycopg2 copying lib\extras.py -> build\lib.win-amd64-3.9\psycopg2 copying lib\pool.py -> build\lib.win-amd64-3.9\psycopg2 copying lib\sql.py -> build\lib.win-amd64-3.9\psycopg2 copying lib\tz.py -> build\lib.win-amd64-3.9\psycopg2 copying lib\_ipaddress.py -> build\lib.win-amd64-3.9\psycopg2 copying lib\_json.py -> build\lib.win-amd64-3.9\psycopg2 copying lib\_lru_cache.py -> build\lib.win-amd64-3.9\psycopg2 copying lib\_range.py -> build\lib.win-amd64-3.9\psycopg2 copying lib\__init__.py -> build\lib.win-amd64-3.9\psycopg2 running build_ext building 'psycopg2._psycopg' extension error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/ ---------------------------------------- ERROR: Command errored out with exit status 1: 'c:\users\aman\appdata\local\programs\python\python39\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Aman\\AppData\\Local\\Temp\\pip-install-8u0ripm3\\psycopg2\\setup.py'"'"'; __file__='"'"'C:\\Users\\Aman\\AppData\\Local\\Temp\\pip-install-8u0ripm3\\psycopg2\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\Aman\AppData\Local\Temp\pip-record-dasbftyv\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\aman\appdata\local\programs\python\python39\Include\psycopg2' Check the logs for full command output.

How do I fix this error?

The error says:

Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/ 

Install this "Build Tools for Visual Studio", probably by following that link. https://visualstudio.microsoft.com/downloads/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM