How to Solve Error Message python setup.py egg_info did not run successfully distutils.errors.DistutilsPlatformError: –plat-name must be one of (‘win32’, ‘win-amd64’, ‘win-arm32’, ‘win-arm64’) when running pip install -r requirements.txt in Microsoft Windows

Posted on

Introduction

Another error which is going for further discussion in this article with the focus on solving it. Actually, this article has a connection with another article in terms of the error message occurrence. Solving the error message in this article is also becoming the solution for solving the error message occur in another article. That article exist in this link with the title of ‘How to Solve Error Message python setup.py egg_info did not run successfully ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129) when running pip install -r requirements.txt in Microsoft Windows’.

Before going further to the solution, below is the line which is indicating or hinting the error message as the main error information :

distutils.errors.DistutilsPlatformError: --plat-name must be one of ('win32', 'win-amd64', 'win-arm32', 'win-arm64')

Basically, the error appear upon executing ‘pip install’ command to install necessary library in a Django project. For the full length of the execution of the command along with the error messages is exist as follows :

(env) c:\repository\docker\django\myproject>pip install -r reqs.txt
Collecting arabic-reshaper==2.1.3
  Using cached arabic_reshaper-2.1.3-py3-none-any.whl (20 kB)
Collecting asgiref==3.5.0
  Using cached asgiref-3.5.0-py3-none-any.whl (22 kB)
Collecting certifi==2020.6.20
  Using cached certifi-2020.6.20-py2.py3-none-any.whl (156 kB)
Requirement already satisfied: charset-normalizer==2.0.12 in c:\repository\docker\django\myproject\env\lib\python3.9\site-packages (from -r reqs.txt (line 5)) (2.0.12)
Collecting click==8.0.3
  Using cached click-8.0.3-py3-none-any.whl (97 kB)
Collecting colorama==0.4.4
  Using cached colorama-0.4.4-py2.py3-none-any.whl (16 kB)
Collecting cryptography==36.0.2
  Downloading cryptography-36.0.2.tar.gz (572 kB)
     ---------------------------------------- 572.1/572.1 kB 79.4 kB/s eta 0:00:00
  Installing build dependencies ... error
  error: subprocess-exited-with-error

  × pip subprocess to install build dependencies did not run successfully.
  │ exit code: 1
  ╰─> [41 lines of output]
      Collecting setuptools>=40.6.0
        Using cached setuptools-62.3.3-py3-none-any.whl (1.2 MB)
      Collecting wheel
        Using cached wheel-0.37.1-py2.py3-none-any.whl (35 kB)
      Collecting cffi>=1.12
        Using cached cffi-1.15.0.tar.gz (484 kB)
        Preparing metadata (setup.py): started
        Preparing metadata (setup.py): finished with status 'error'
        error: subprocess-exited-with-error

        python setup.py egg_info did not run successfully.
        exit code: 1

        [16 lines of output]
        Traceback (most recent call last):
          File "", line 2, in 
          File "", line 34, in 
          File "C:\Users\Personal\AppData\Local\Temp\pip-install-wc0sqjej\cffi_5c45c8bd835d412f800b7fad3fe6ec04\setup.py", line 126, in 
            if sys.platform == "win32" and uses_msvc():
          File "C:\Users\Personal\AppData\Local\Temp\pip-install-wc0sqjej\cffi_5c45c8bd835d412f800b7fad3fe6ec04\setup.py", line 105, in uses_msvc
            return config.try_compile('#ifndef _MSC_VER\n#error "not MSVC"\n#endif')
          File "C:\repository\docker\django\myproject\env\lib\python3.9\site-packages\setuptools\_distutils\command\config.py", line 225, in try_compile
            self._compile(body, headers, include_dirs, lang)
          File "C:\repository\docker\django\myproject\env\lib\python3.9\site-packages\setuptools\_distutils\command\config.py", line 132, in _compile
            self.compiler.compile([src], include_dirs=include_dirs)
          File "C:\repository\docker\django\myproject\env\lib\python3.9\site-packages\setuptools\_distutils\_msvccompiler.py", line 327, in compile
            self.initialize()
          File "C:\repository\docker\django\myproject\env\lib\python3.9\site-packages\setuptools\_distutils\_msvccompiler.py", line 218, in initialize
            raise DistutilsPlatformError("--plat-name must be one of {}"
        distutils.errors.DistutilsPlatformError: --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: metadata-generation-failed

      Encountered error while generating package metadata.

      See above for output.

      note: This is an issue with the package mentioned above, not pip.
      hint: See above for details.
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× pip subprocess to install build dependencies did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

(env) C:\repository\docker\django\myproject>

How to Solve Error Message distutils.errors.DistutilsPlatformError: –plat-name must be one of (‘win32’, ‘win-amd64’, ‘win-arm32’, ‘win-arm64’)

The solution is very simple. It is changing the python version which is supporting the project indirectly. It also change the python virtual environment where the base of the python used is referring to the currently active python in the operating system. So, the following is the actual step in order to solve the problem :

  1. First of all, it is checking the current version of the active pip in the operating system as follows :

    C:\Users\Personal>pip -V
    pip 22.1.2 from C:\Program Files\Inkscape\lib\python3.9\site-packages\pip (python 3.9)
    
    C:\Users\Personal>
    
  2. Continue and move on, just check the python version exist in the project. Precisely, the python version in the virtual python environment used by the project. In order to do that activate the virtual python environment as follows :

    C:\Users\Personal> cd C:\repository\docker\django\myproject\env\bin
    C:\repository\docker\django\myproject\env\bin> activate
    (env) C:\repository\docker\django\myproject>python -V
    Python 3.9.10
    
    (env) C:\repository\docker\django\myproject\env\bin>
    

    In that case, just search another python version which has a different version and it is not a python version which is an additional version from another application. In this example, the python library is from Inkscape application as exist in the above command checking the pip version. That line is :

    'pip 22.1.2 from C:\Program Files\Inkscape\lib\python3.9\site-packages\pip (python 3.9)'

    Just use the official version of the python available in the python official website. As a reference, read the article in this link with the title of ‘How to Install Python in Microsoft Windows 11’.

    Do not forget to add it to the environment variable in the operating system if the ‘python’ command is not available for execution in the Command Prompt. Just look in the article with the title of ‘How to Add Executable Python Path in Microsoft Windows 11’ in this link for further information. Moreover, since there are multiple executable python path, set the default executable python to the newest python installation instead. Look in the article with the title of ‘How to Set Default Executable Python from Multiple Python available in Microsoft Windows’ in this link for more explanation.

  3. After the installation of the new version of the Python, just check the version once more as follows :

    C:\repository\docker\django\myproject>python -V
    Python 3.10.5
    
    C:\repository\docker\django\myproject>
    

    Fortunately, the current version of the Python is already a different one. The previous one is the ‘3.9.10’ from the Inkscape application. And in the current one, it is ‘3.10.5’ from the official Python official website resource.

  4. Continue on further, using that version of Python, just create the virtual python environment by executing the following command :

    C:\repository\docker\django\myproject>virtualenv --python "C:\users\Personal\AppData\Local\Programs\Python\Python310\python.exe" virtualenv
    created virtual environment CPython3.10.5.final.0-64 in 1257ms
      creator CPython3Windows(dest=C:\repository\docker\django\myproject\virtualenv, clear=False, no_vcs_ignore=False, global=False)
      seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=C:\Users\Personal\AppData\Local\pypa\virtualenv)
        added seed packages: pip==22.0.4, setuptools==62.1.0, wheel==0.37.1
      activators BashActivator,BatchActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator
    
    C:\repository\docker\django\myproject>
    
  5. After that, just go on to the python virtual environment and then activate it as follows :

    C:\repository\docker\django\myproject>cd virtualenv
    
    C:\repository\docker\django\myproject\virtualenv>dir
     Volume in drive C is Windows-SSD
     Volume Serial Number is CA30-19A4
    
     Directory of C:\repository\docker\django\myproject\virtualenv
    
    06/12/2022 01:33 PM <DIR> .
    06/12/2022 01:33 PM <DIR> ..
    06/12/2022 01:33 PM 42 .gitignore
    06/12/2022 01:33 PM <DIR> Lib
    06/12/2022 01:33 PM 434 pyvenv.cfg
    06/12/2022 01:33 PM <DIR> Scripts
    2 File(s) 476 bytes
    4 Dir(s) 139,783,331,840 bytes free
    C:\repository\docker\django\myproject\virtualenv>cd Scripts
    
    C:\repository\docker\django\myproject\virtualenv\Scripts>dir
    Volume in drive C is Windows-SSD
    Volume Serial Number is CA30-19A4
    
    Directory of C:\repository\docker\django\myproject\virtualenv\Scripts
    
    06/12/2022 01:33 PM <DIR> .
    06/12/2022 01:33 PM <DIR> ..
    06/12/2022 01:33 PM 2,168 activate
    06/12/2022 01:33 PM 1,008 activate.bat
    06/12/2022 01:33 PM 3,045 activate.fish
    06/12/2022 01:33 PM 2,609 activate.nu
    06/12/2022 01:33 PM 1,758 activate.ps1
    06/12/2022 01:33 PM 1,193 activate_this.py
    06/12/2022 01:33 PM 510 deactivate.bat
    06/12/2022 01:33 PM 682 deactivate.nu
    06/12/2022 01:33 PM 106,887 pip-3.10.exe
    06/12/2022 01:33 PM 106,887 pip.exe
    06/12/2022 01:33 PM 106,887 pip3.10.exe
    06/12/2022 01:33 PM 106,887 pip3.exe
    06/12/2022 01:33 PM 24 pydoc.bat
    06/12/2022 01:33 PM 264,176 python.exe
    06/12/2022 01:33 PM 252,912 pythonw.exe
    06/12/2022 01:33 PM 106,874 wheel-3.10.exe
    06/12/2022 01:33 PM 106,874 wheel.exe
    06/12/2022 01:33 PM 106,874 wheel3.10.exe
    06/12/2022 01:33 PM 106,874 wheel3.exe
    19 File(s) 1,385,129 bytes
    2 Dir(s) 139,783,249,920 bytes free
    
    C:\repository\docker\django\myproject\virtualenv\Scripts>activate
    
    (virtualenv) C:\repository\docker\django\myproject\virtualenv\Scripts>
    
  6. Soon after the activation of the virtual python environment is a success, go back the root folder of the project.

    (virtualenv) C:\repository\docker\django\myproject\virtualenv\Scripts>cd ..
    
    (virtualenv) C:\repository\docker\django\myproject\virtualenv>cd ..
    
    (virtualenv) C:\repository\docker\django\myproject\>dir
    Volume in drive C is Windows-SSD
    Volume Serial Number is CA30-19A4
    
    Directory of C:\repository\docker\django\myproject
    
    06/12/2022 01:13 PM <DIR> .
    06/12/2022 01:33 PM <DIR> ..
    06/08/2022 02:30 PM <DIR>         config 
    04/01/2022 05:08 PM       188,416 db.sqlite3 
    02/07/2022 09:35 AM           684 manage.py 
    04/01/2022 08:05 AM <DIR>         media 
    06/08/2022 02:30 PM <DIR>         modules 
    06/13/2022 09:15 AM           818 reqs.txt 
    06/08/2022 02:30 PM <DIR>         static 
    06/08/2022 02:31 PM <DIR>         templates 
    06/12/2022 01:13 PM <DIR>         virtualenv 
                  3 File(s) 189,918 bytes 
                  8 Dir(s) 138,646,548,480 bytes free 
    (virtualenv) C:\repository\docker\django\myproject>
    
  7. Last but not least, just run the command of ‘pip install’ once more as follows :
    (virtualenv) C:\repository\docker\django\myproject>pip install -r reqs.txt
    Requirement already satisfied: arabic-reshaper==2.1.3 in c:\repository\docker\django\myproject\virtualenv\lib\site-packages (from -r reqs.txt (line 1)) (2.1.3)
    Requirement already satisfied: asgiref==3.5.0 in c:\repository\docker\django\myproject\virtualenv\lib\site-packages (from -r reqs.txt (line 2)) (3.5.0)
    Requirement already satisfied: certifi==2020.6.20 in c:\repository\docker\django\myproject\virtualenv\lib\site-packages (from -r reqs.txt (line 3)) (2020.6.20)
    Collecting cffi==1.15.0
      Downloading cffi-1.15.0-cp310-cp310-win_amd64.whl (180 kB)
         ---------------------------------------- 180.3/180.3 kB 518.4 kB/s eta 0:00:00
    Requirement already satisfied: charset-normalizer==2.0.12 in c:\repository\docker\django\myproject\virtualenv\lib\site-packages (from -r reqs.txt (line 5)) (2.0.12)
    Requirement already satisfied: click==8.0.3 in c:\repository\docker\django\myproject\virtualenv\lib\site-packages (from -r reqs.txt (line 6)) (8.0.3)
    Requirement already satisfied: colorama==0.4.4 in c:\repository\docker\django\myproject\virtualenv\lib\site-packages (from -r reqs.txt (line 7)) (0.4.4)
    Requirement already satisfied: cssselect2==0.5.0 in c:\repository\docker\django\myproject\virtualenv\lib\site-packages (from -r reqs.txt (line 9)) (0.5.0)
    Requirement already satisfied: defusedxml==0.7.1 in c:\repository\docker\django\myproject\virtualenv\lib\site-packages (from -r reqs.txt (line 10)) (0.7.1)
    Requirement already satisfied: Django==4.0.2 in c:\repository\docker\django\myproject\virtualenv\lib\site-packages (from -r reqs.txt (line 11)) (4.0.2)
    Requirement already satisfied: flake8==4.0.1 in c:\repository\docker\django\myproject\virtualenv\lib\site-packages (from -r reqs.txt (line 12)) (4.0.1)
    Requirement already satisfied: future==0.18.2 in c:\repository\docker\django\myproject\virtualenv\lib\site-packages (from -r reqs.txt (line 13)) (0.18.2)
    Requirement already satisfied: html5lib==1.1 in c:\repository\docker\django\myproject\virtualenv\lib\site-packages (from -r reqs.txt (line 14)) (1.1)
    Requirement already satisfied: idna==3.3 in c:\repository\docker\django\myproject\virtualenv\lib\site-packages (from -r reqs.txt (line 15)) (3.3)
    Requirement already satisfied: ldap3==2.9.1 in c:\repository\docker\django\myproject\virtualenv\lib\site-packages (from -r reqs.txt (line 16)) (2.9.1)
    Requirement already satisfied: lxml==4.8.0 in c:\repository\docker\django\myproject\virtualenv\lib\site-packages (from -r reqs.txt (line 17)) (4.8.0)
    Requirement already satisfied: mccabe==0.6.1 in c:\repository\docker\django\myproject\virtualenv\lib\site-packages (from -r reqs.txt (line 18)) (0.6.1)
    Requirement already satisfied: mypy-extensions==0.4.3 in c:\repository\docker\django\myproject\virtualenv\lib\site-packages (from -r reqs.txt (line 19)) (0.4.3)
    Requirement already satisfied: oauthlib==3.2.0 in c:\repository\docker\django\myproject\virtualenv\lib\site-packages (from -r reqs.txt (line 20)) (3.2.0)
    Requirement already satisfied: pathspec==0.9.0 in c:\repository\docker\django\myproject\virtualenv\lib\site-packages (from -r reqs.txt (line 21)) (0.9.0)
    Requirement already satisfied: Pillow==9.0.1 in c:\repository\docker\django\myproject\virtualenv\lib\site-packages (from -r reqs.txt (line 22)) (9.0.1)
    Requirement already satisfied: platformdirs==2.5.1 in c:\repository\docker\django\myproject\virtualenv\lib\site-packages (from -r reqs.txt (line 23)) (2.5.1)
    Requirement already satisfied: pyasn1==0.4.8 in c:\repository\docker\django\myproject\virtualenv\lib\site-packages (from -r reqs.txt (line 24)) (0.4.8)
    Requirement already satisfied: pycodestyle==2.8.0 in c:\repository\docker\django\myproject\virtualenv\lib\site-packages (from -r reqs.txt (line 25)) (2.8.0)
    Requirement already satisfied: pycparser==2.21 in c:\repository\docker\django\myproject\virtualenv\lib\site-packages (from -r reqs.txt (line 26)) (2.21)
    Requirement already satisfied: pyflakes==2.4.0 in c:\repository\docker\django\myproject\virtualenv\lib\site-packages (from -r reqs.txt (line 27)) (2.4.0)
    Requirement already satisfied: PyJWT==2.3.0 in c:\repository\docker\django\myproject\virtualenv\lib\site-packages (from -r reqs.txt (line 28)) (2.3.0)
    Requirement already satisfied: PyPDF3==1.0.6 in c:\repository\docker\django\myproject\virtualenv\lib\site-packages (from -r reqs.txt (line 29)) (1.0.6)
    Requirement already satisfied: python-bidi==0.4.2 in c:\repository\docker\django\myproject\virtualenv\lib\site-packages (from -r reqs.txt (line 30)) (0.4.2)
    Requirement already satisfied: python3-openid==3.2.0 in c:\repository\docker\django\myproject\virtualenv\lib\site-packages (from -r reqs.txt (line 31)) (3.2.0)
    Collecting reportlab==3.6.9
      Downloading reportlab-3.6.9-cp310-cp310-win_amd64.whl (2.3 MB)
         ---------------------------------------- 2.3/2.3 MB 156.4 kB/s eta 0:00:00
    Requirement already satisfied: requests==2.27.1 in c:\repository\docker\django\myproject\virtualenv\lib\site-packages (from -r reqs.txt (line 33)) (2.27.1)
    Requirement already satisfied: requests-oauthlib==1.3.1 in c:\repository\docker\django\myproject\virtualenv\lib\site-packages (from -r reqs.txt (line 34)) (1.3.1)
    Requirement already satisfied: six==1.16.0 in c:\repository\docker\django\myproject\virtualenv\lib\site-packages (from -r reqs.txt (line 35)) (1.16.0)
    Requirement already satisfied: spark-parser==1.8.9 in c:\repository\docker\django\myproject\virtualenv\lib\site-packages (from -r reqs.txt (line 36)) (1.8.9)
    Requirement already satisfied: sqlparse==0.4.2 in c:\repository\docker\django\myproject\virtualenv\lib\site-packages (from -r reqs.txt (line 37)) (0.4.2)
    Requirement already satisfied: svglib==1.2.1 in c:\repository\docker\django\myproject\virtualenv\lib\site-packages (from -r reqs.txt (line 38)) (1.2.1)
    Requirement already satisfied: tinycss2==1.1.1 in c:\repository\docker\django\myproject\virtualenv\lib\site-packages (from -r reqs.txt (line 39)) (1.1.1)
    Collecting tomli==2.0.1
      Using cached tomli-2.0.1-py3-none-any.whl (12 kB)
    Collecting tqdm==4.63.1
      Using cached tqdm-4.63.1-py2.py3-none-any.whl (76 kB)
    Collecting tzdata==2021.5
      Using cached tzdata-2021.5-py2.py3-none-any.whl (339 kB)
    Requirement already satisfied: urllib3==1.26.9 in c:\repository\docker\django\myproject\virtualenv\lib\site-packages (from -r reqs.txt (line 43)) (1.26.9)
    Requirement already satisfied: webencodings==0.5.1 in c:\repository\docker\django\myproject\virtualenv\lib\site-packages (from -r reqs.txt (line 44)) (0.5.1)
    Collecting wincertstore==0.2
      Using cached wincertstore-0.2-py2.py3-none-any.whl (8.8 kB)
    Collecting xdis==6.0.3
      Downloading xdis-6.0.3-py310-none-any.whl (134 kB)
         ---------------------------------------- 134.3/134.3 kB 203.7 kB/s eta 0:00:00
    Collecting xhtml2pdf==0.2.6
      Using cached xhtml2pdf-0.2.6-py3-none-any.whl (239 kB)
    Requirement already satisfied: setuptools in c:\repository\docker\django\myproject\virtualenv\lib\site-packages (from arabic-reshaper==2.1.3->-r reqs.txt (line 1)) (62.1.0)
    Installing collected packages: wincertstore, tzdata, tqdm, tomli, reportlab, cffi, xdis, xhtml2pdf
      Attempting uninstall: tzdata
        Found existing installation: tzdata 2022.1
        Uninstalling tzdata-2022.1:
          Successfully uninstalled tzdata-2022.1
      Attempting uninstall: tqdm
        Found existing installation: tqdm 4.64.0
        Uninstalling tqdm-4.64.0:
          Successfully uninstalled tqdm-4.64.0
      Attempting uninstall: reportlab
        Found existing installation: reportlab 3.6.10
        Uninstalling reportlab-3.6.10:
          Successfully uninstalled reportlab-3.6.10
    Successfully installed cffi-1.15.0 reportlab-3.6.9 tomli-2.0.1 tqdm-4.63.1 tzdata-2021.5 wincertstore-0.2 xdis-6.0.3 xhtml2pdf-0.2.6
    
    (virtualenv) C:\repository\docker\django\myproject>
    

At last, the solution for changing the python and creating the python virtual environment once more is solving the problem.

Leave a Reply