Introduction
This article actually is another version of the other version available. That version is an article with the title of ‘How to Solve Error Message ERROR: Failed building wheel for psycopg2 when installing psycopg2 using pip command’ and it exist in this link. This article is just another version only with the different title. The other article is focusing on the error of ‘ERROR: Failed building wheel for psycopg2’. But this article, there is another general error of ‘error: subprocess-exited-with-error’. So, the following is part of the error :
Building wheel for psycopg2 (setup.py) ... error error: subprocess-exited-with-error × python setup.py bdist_wheel did not run successfully. │ exit code: 1 ╰─> [22 lines of output] C:\repository\django\env\lib\python3.9\site-packages\setuptools\config\setupcfg.py:463: SetuptoolsDeprecationWarning: The license_file parameter is deprecated, use license_files instead. warnings.warn(msg, warning_class)
On the other hand, the following is the full length of the error message appear. The trigger is the installation of ‘psycopg2’ python library. Furthermore, the installation is using pip command in a device running using Microsoft Windows operating system :
(env) C:\repository\django\env\bin>pip install psycopg2 Collecting psycopg2 Using cached psycopg2-2.9.3.tar.gz (380 kB) Preparing metadata (setup.py) ... done Building wheels for collected packages: psycopg2 Building wheel for psycopg2 (setup.py) ... error error: subprocess-exited-with-error × python setup.py bdist_wheel did not run successfully. │ exit code: 1 ╰─> [22 lines of output] C:\repository\django\env\lib\python3.9\site-packages\setuptools\config\setupcfg.py:463: SetuptoolsDeprecationWarning: The license_file parameter is deprecated, use license_files instead. warnings.warn(msg, warning_class) running bdist_wheel running build running build_py creating build creating build\lib.mingw_x86_64-cpython-39 creating build\lib.mingw_x86_64-cpython-39\psycopg2 copying lib\errorcodes.py -> build\lib.mingw_x86_64-cpython-39\psycopg2 copying lib\errors.py -> build\lib.mingw_x86_64-cpython-39\psycopg2 copying lib\extensions.py -> build\lib.mingw_x86_64-cpython-39\psycopg2 copying lib\extras.py -> build\lib.mingw_x86_64-cpython-39\psycopg2 copying lib\pool.py -> build\lib.mingw_x86_64-cpython-39\psycopg2 copying lib\sql.py -> build\lib.mingw_x86_64-cpython-39\psycopg2 copying lib\tz.py -> build\lib.mingw_x86_64-cpython-39\psycopg2 copying lib\_ipaddress.py -> build\lib.mingw_x86_64-cpython-39\psycopg2 copying lib\_json.py -> build\lib.mingw_x86_64-cpython-39\psycopg2 copying lib\_range.py -> build\lib.mingw_x86_64-cpython-39\psycopg2 copying lib\__init__.py -> build\lib.mingw_x86_64-cpython-39\psycopg2 running build_ext building 'psycopg2._psycopg' extension error: --plat-name must be one of ('win32', 'win-amd64', 'win-arm32', 'win-arm64') [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for psycopg2 Running setup.py clean for psycopg2 Failed to build psycopg2 Installing collected packages: psycopg2 Running setup.py install for psycopg2 ... error error: subprocess-exited-with-error × Running setup.py install for psycopg2 did not run successfully. │ exit code: 1 ╰─> [24 lines of output] C:\repository\django\env\lib\python3.9\site-packages\setuptools\config\setupcfg.py:463: SetuptoolsDeprecationWarning: The license_file parameter is deprecated, use license_files instead. warnings.warn(msg, warning_class) running install C:\repository\django\env\lib\python3.9\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools. warnings.warn( running build running build_py creating build creating build\lib.mingw_x86_64-cpython-39 creating build\lib.mingw_x86_64-cpython-39\psycopg2 copying lib\errorcodes.py -> build\lib.mingw_x86_64-cpython-39\psycopg2 copying lib\errors.py -> build\lib.mingw_x86_64-cpython-39\psycopg2 copying lib\extensions.py -> build\lib.mingw_x86_64-cpython-39\psycopg2 copying lib\extras.py -> build\lib.mingw_x86_64-cpython-39\psycopg2 copying lib\pool.py -> build\lib.mingw_x86_64-cpython-39\psycopg2 copying lib\sql.py -> build\lib.mingw_x86_64-cpython-39\psycopg2 copying lib\tz.py -> build\lib.mingw_x86_64-cpython-39\psycopg2 copying lib\_ipaddress.py -> build\lib.mingw_x86_64-cpython-39\psycopg2 copying lib\_json.py -> build\lib.mingw_x86_64-cpython-39\psycopg2 copying lib\_range.py -> build\lib.mingw_x86_64-cpython-39\psycopg2 copying lib\__init__.py -> build\lib.mingw_x86_64-cpython-39\psycopg2 running build_ext building 'psycopg2._psycopg' extension error: --plat-name must be one of ('win32', 'win-amd64', 'win-arm32', 'win-arm64') [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. error: legacy-install-failure × Encountered error while trying to install package. ╰─> psycopg2 note: This is an issue with the package mentioned above, not pip. hint: See above for output from the failure. (env) C:\repository\django\env\bin> (env) C:\repository\django\env\bin>python -V Python 3.9.10 (env) C:\repository\django\env\bin>
How to Solve Error Message Building wheel for psycopg2 (setup.py) … error error: subprocess-exited-with-error
So, the solution is actually the exact same solution for solving the problem exist in the other article. So, the following is actually the sequence for solving the problem which is actually just replacing the old python virtual environment with a new one. Additionally, that new python virtual environment has a different python version as its base. For the sequences, the following is the actual steps as the solution :
-
First step, create the new python virtual environment. The process is not using ‘virtualenv env’ command. Instead, use another command to create the python virtual environment as follows :
<pre>C:\repository\django>python -m venv venv C:\repository\django>cd venv (venv) C:\repository\django\venv>dir Volume in drive C is Windows-SSD Volume Serial Number is CA30-19A4 Directory of C:\repository\django\venv 07/17/2022 03:08 PM <DIR> . 07/17/2022 03:08 PM <DIR> .. 07/17/2022 03:08 PM <DIR> Include 07/17/2022 03:08 PM <DIR> Lib 07/17/2022 03:08 PM 84 pyvenv.cfg 07/17/2022 03:08 PM <DIR> Scripts 1 File(s) 84 bytes 5 Dir(s) 147,161,825,280 bytes free C:\repository\django\venv>
-
Following after, just access the ‘Scripts’ folder as follows :
C:\repository\django\venv>cd Scripts C:\repository\django\venv\Scripts>dir Volume in drive C is Windows-SSD Volume Serial Number is CA30-19A4 Directory of C:\repository\django\venv\Scripts 07/17/2022 03:08 PM <DIR> . 07/17/2022 03:08 PM <DIR> .. 07/17/2022 03:08 PM 2,072 activate 07/17/2022 03:08 PM 1,001 activate.bat 07/17/2022 03:08 PM 22,159 Activate.ps1 07/17/2022 03:08 PM 393 deactivate.bat 07/17/2022 03:08 PM 106,362 pip.exe 07/17/2022 03:08 PM 106,362 pip3.10.exe 07/17/2022 03:08 PM 106,362 pip3.exe 07/17/2022 03:08 PM 264,176 python.exe 07/17/2022 03:08 PM 252,912 pythonw.exe 9 File(s) 861,799 bytes 2 Dir(s) 147,161,825,280 bytes free C:\repository\django\venv\Scripts>cd ..
-
In that folder, there is a file with the name of ‘activate’. It is a file for activating the python virtual environment. The command execution for activating that command is just by executing the command ‘activate’ as follows :
C:\repository\django\venv\Scripts>activate (venv) C:\repository\django\venv\Scripts>
-
After the activation, just execute the following command for check the version of the python. It is a base python for the python virtual environment :
(venv) C:\repository\django\venv\Scripts>python -V Python 3.10.5 (venv) C:\repository\django\venv\Scripts>
-
Finally, just execute the command for installing ‘psycopg2’ python library once more as follows :
(venv) C:\repository\django\venv\Scripts>pip install psycopg2 Collecting psycopg2 Using cached psycopg2-2.9.3-cp310-cp310-win_amd64.whl (1.2 MB) Installing collected packages: psycopg2 Successfully installed psycopg2-2.9.3 (venv) C:\repository\django\venv\Scripts>
At last, the execution command for installing ‘psycopg2’ python library is a success.