How to Solve Error Message Command “python setup.py egg_info” failed with error code 1 in /tmp/pip-build-XPwxXf/charset-normalizer/ when running pip install

Posted on

Introduction

Actually, the main purpose of this article is to solve an error message appear. It is basically referring to the actual occurrence where the error happened. The error message appear when executing a ‘pip install command’. Upon executing the command for installing necessary module or library specified in the requirements.txt file, the error appear. The following is the actual execution of the command which is triggering the error message to appear :

[django@localhost project]$ pip install -r requirements.txt
Collecting asgiref==3.4.1 (from -r requirements.txt (line 1))
Downloading https://files.pythonhosted.org/packages/07/93/3618b68b4ba6b54bc97b5fd7d90e4981471edfaf51c8321a29a3c76cf47c/asgiref-3.4.1.tar.gz
Running setup.py (path:/tmp/pip-build-XPwxXf/asgiref/setup.py) egg_info for package asgiref produced metadata for project name unknown. Fix your #egg=asgiref fragments.
Requirement already satisfied (use --upgrade to upgrade): unknown from https://files.pythonhosted.org/packages/07/93/3618b68b4ba6b54bc97b5fd7d90e4981471edfaf51c8321a29a3c76cf47c/asgiref-3.4.1.tar.gz#sha256=4ef1ab46b484e3c706329cedeff284a5d40824200638503f5768edb6de7d58e9 in /usr/lib/python2.7/site-packages (from -r requirements.txt (line 1))
Collecting autopep8==1.5.7 (from -r requirements.txt (line 2))
Downloading https://files.pythonhosted.org/packages/a7/f6/84070ab117e6b080a87aac0ac9e4d269a66c6f6076ad81509bd0aac828d8/autopep8-1.5.7-py2.py3-none-any.whl (45kB)
100% |████████████████████████████████| 51kB 904kB/s
Collecting cachetools==4.2.4 (from -r requirements.txt (line 3))
Downloading https://files.pythonhosted.org/packages/d7/69/c457a860456cbf80ecc2e44ed4c201b49ec7ad124d769b71f6d0a7935dca/cachetools-4.2.4.tar.gz
Running setup.py (path:/tmp/pip-build-XPwxXf/cachetools/setup.py) egg_info for package cachetools produced metadata for project name unknown. Fix your #egg=cachetools fragments.
Requirement already satisfied (use --upgrade to upgrade): unknown from https://files.pythonhosted.org/packages/d7/69/c457a860456cbf80ecc2e44ed4c201b49ec7ad124d769b71f6d0a7935dca/cachetools-4.2.4.tar.gz#sha256=89ea6f1b638d5a73a4f9226be57ac5e4f399d22770b92355f92dcb0f7f001693 in /usr/lib/python2.7/site-packages (from -r requirements.txt (line 3))
Collecting certifi==2021.5.30 (from -r requirements.txt (line 4))
Downloading https://files.pythonhosted.org/packages/05/1b/0a0dece0e8aa492a6ec9e4ad2fe366b511558cdc73fd3abc82ba7348e875/certifi-2021.5.30-py2.py3-none-any.whl (145kB)
100% |████████████████████████████████| 153kB 4.7MB/s
Collecting charset-normalizer==2.0.7 (from -r requirements.txt (line 5))
Downloading https://files.pythonhosted.org/packages/9f/c5/334c019f92c26e59637bb42bd14a190428874b2b2de75a355da394cf16c1/charset-normalizer-2.0.7.tar.gz (362kB)
100% |████████████████████████████████| 368kB 2.8MB/s
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-XPwxXf/charset-normalizer/setup.py", line 44, in <module>
long_description=long_description.replace(':heavy_check_mark:', '✅'),
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 0: ordinal not in range(128)

----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-XPwxXf/charset-normalizer/

After facing the error above while thinking about the solution, the following are the attempt for solving the problem :

Try to update the version of the ‘pip’ by executing the following command :

[django@localhost project]$ python3 -m pip install -U pip
Collecting pip
Downloading https://files.pythonhosted.org/packages/a4/6d/6463d49a933f547439d6b5b98b46af8742cc03ae83543e4d7688c2420f8b/pip-21.3.1-py3-none-any.whl (1.7MB)
100% |████████████████████████████████| 1.7MB 678kB/s
Installing collected packages: pip
Exception:
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/usr/lib/python3.6/site-packages/pip/commands/install.py", line 365, in run
strip_file_prefix=options.strip_file_prefix,
File "/usr/lib/python3.6/site-packages/pip/req/req_set.py", line 789, in install
**kwargs
File "/usr/lib/python3.6/site-packages/pip/req/req_install.py", line 854, in install
strip_file_prefix=strip_file_prefix
File "/usr/lib/python3.6/site-packages/pip/req/req_install.py", line 1069, in move_wheel_files
strip_file_prefix=strip_file_prefix,
File "/usr/lib/python3.6/site-packages/pip/wheel.py", line 345, in move_wheel_files
clobber(source, lib_dir, True)
File "/usr/lib/python3.6/site-packages/pip/wheel.py", line 287, in clobber
ensure_dir(dest) # common for the 'include' path
File "/usr/lib/python3.6/site-packages/pip/utils/__init__.py", line 83, in ensure_dir
os.makedirs(path)
File "/usr/lib64/python3.6/os.py", line 210, in makedirs
makedirs(head, mode, exist_ok)
File "/usr/lib64/python3.6/os.py", line 220, in makedirs
mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/usr/local/lib/python3.6'

[django@localhost project]$
[django@localhost project]$ exit
logout

Solution

As the previous attempt for solving the problem end in failure, there are an article posting about the solution. It exist in the following article in this link. Actually, the attempt in the previous part is a solution to solve it. But instead of using a standard user, use super user or root account as follows :

  1. Doing the same command, but in this time as a ‘root’ or a super user, just execute the command once more :

    [root@localhost django]# python3 -m pip install -U pip
    WARNING: Running pip install with root privileges is generally not a good idea. Try `__main__.py install --user` instead.
    Collecting pip
    Downloading https://files.pythonhosted.org/packages/a4/6d/6463d49a933f547439d6b5b98b46af8742cc03ae83543e4d7688c2420f8b/pip-21.3.1-py3-none-any.whl (1.7MB)
    100% |████████████████████████████████| 1.7MB 691kB/s
    Installing collected packages: pip
    Successfully installed pip-21.3.1
    [root@localhost django]#
    
  2. Not only upgrading the ‘pip’ tool, but also the setuptools by executing the same command with a different parameter value as follows :

     
    [root@localhost django]# python3 -m pip install -U setuptools 
    Requirement already satisfied: setuptools in /usr/lib/python3.6/site-packages (39.2.0) 
    Collecting setuptools 
    Downloading setuptools-59.1.1-py3-none-any.whl (951 kB) |████████████████████████████████| 951 kB 1.8 MB/s 
    Installing collected packages: setuptools 
    Attempting uninstall: setuptools 
    Found existing installation: setuptools 39.2.0 
    Uninstalling setuptools-39.2.0: 
    Successfully uninstalled setuptools-39.2.0 
    Successfully installed setuptools-59.1.1 
    WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. 
    It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv 
    [root@localhost django]#
    
  3. Finally, just execute the command ‘pip install’ once more as in the introduction part below :
    (env) [django@localhost django]$ pip install -r requirements.txt
    Collecting asgiref==3.4.1
    Downloading asgiref-3.4.1-py3-none-any.whl (25 kB)
    Collecting autopep8==1.5.7
    Using cached autopep8-1.5.7-py2.py3-none-any.whl (45 kB)
    Collecting cachetools==4.2.4
    Downloading cachetools-4.2.4-py3-none-any.whl (10 kB)
    Collecting certifi==2021.5.30
    Using cached certifi-2021.5.30-py2.py3-none-any.whl (145 kB)
    Collecting charset-normalizer==2.0.7
    Downloading charset_normalizer-2.0.7-py3-none-any.whl (38 kB)
    Collecting dj-database-url==0.5.0
    Downloading dj_database_url-0.5.0-py2.py3-none-any.whl (5.5 kB)
    Collecting Django==3.2.6
    Downloading Django-3.2.6-py3-none-any.whl (7.9 MB)
    |████████████████████████████████| 7.9 MB 4.5 MB/s
    Collecting django-ckeditor==6.1.0
    Downloading django_ckeditor-6.1.0-py2.py3-none-any.whl (2.4 MB)
    |████████████████████████████████| 2.4 MB 84.0 MB/s
    Collecting django-js-asset==1.2.2
    Downloading django_js_asset-1.2.2-py2.py3-none-any.whl (5.8 kB)
    Collecting docutils==0.17.1
    Downloading docutils-0.17.1-py2.py3-none-any.whl (575 kB)
    |████████████████████████████████| 575 kB 101.3 MB/s
    Collecting environ==1.0
    Downloading environ-1.0.tar.gz (2.6 kB)
    Preparing metadata (setup.py) ... done
    Collecting gunicorn==20.1.0
    Downloading gunicorn-20.1.0-py3-none-any.whl (79 kB)
    |████████████████████████████████| 79 kB 759 kB/s
    Collecting idna==3.3
    Downloading idna-3.3-py3-none-any.whl (61 kB)
    |████████████████████████████████| 61 kB 1.2 MB/s
    Collecting Pillow==8.3.2
    Downloading Pillow-8.3.2-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.0 MB)
    |████████████████████████████████| 3.0 MB 74.9 MB/s
    Collecting protobuf==3.19.0
    Downloading protobuf-3.19.0-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB)
    |████████████████████████████████| 1.1 MB 71.8 MB/s
    Collecting pyasn1==0.4.8
    Downloading pyasn1-0.4.8-py2.py3-none-any.whl (77 kB)
    |████████████████████████████████| 77 kB 1.0 MB/s
    Collecting pyasn1-modules==0.2.8
    Downloading pyasn1_modules-0.2.8-py2.py3-none-any.whl (155 kB)
    |████████████████████████████████| 155 kB 89.5 MB/s
    Collecting pycodestyle==2.7.0
    Downloading pycodestyle-2.7.0-py2.py3-none-any.whl (41 kB)
    |████████████████████████████████| 41 kB 72 kB/s
    Collecting python-decouple==3.4
    Downloading python_decouple-3.4-py3-none-any.whl (9.5 kB)
    Collecting pytz==2021.1
    Downloading pytz-2021.1-py2.py3-none-any.whl (510 kB)
    |████████████████████████████████| 510 kB 97.2 MB/s
    Collecting requests==2.26.0
    Downloading requests-2.26.0-py2.py3-none-any.whl (62 kB)
    |████████████████████████████████| 62 kB 154 kB/s
    Collecting rsa==4.7.2
    Downloading rsa-4.7.2-py3-none-any.whl (34 kB)
    Collecting six==1.16.0
    Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
    Collecting sqlparse==0.4.2
    Downloading sqlparse-0.4.2-py3-none-any.whl (42 kB)
    |████████████████████████████████| 42 kB 133 kB/s
    Collecting toml==0.10.2
    Downloading toml-0.10.2-py2.py3-none-any.whl (16 kB)
    Collecting Unipath==1.1
    Downloading Unipath-1.1.tar.gz (30 kB)
    Preparing metadata (setup.py) ... done
    Collecting urllib3==1.26.7
    Downloading urllib3-1.26.7-py2.py3-none-any.whl (138 kB)
    |████████████████████████████████| 138 kB 94.1 MB/s
    Collecting whitenoise==5.3.0
    Downloading whitenoise-5.3.0-py2.py3-none-any.whl (19 kB)
    Collecting wincertstore==0.2
    Downloading wincertstore-0.2-py2.py3-none-any.whl (8.8 kB)
    Collecting typing-extensions
    Using cached typing_extensions-4.0.0-py3-none-any.whl (22 kB)
    Requirement already satisfied: setuptools>=3.0 in /home/django/env/lib/python3.6/site-packages (from gunicorn==20.1.0->-r requirements.txt (line 12)) (58.3.0)
    Building wheels for collected packages: environ, Unipath
    Building wheel for environ (setup.py) ... done
    Created wheel for environ: filename=environ-1.0-py3-none-any.whl size=3247 sha256=aacab5a660718aadde2d6b0e547b097b51e8419ef2cca426490c01ac21f175a8
    Stored in directory: /home/django/.cache/pip/wheels/fb/65/b4/382c767bd57e41b3ab4a63b947eeadbe45caf2b2fa1803024b
    Building wheel for Unipath (setup.py) ... done
    Created wheel for Unipath: filename=Unipath-1.1-py3-none-any.whl size=9125 sha256=77e27802bc7f9cf220a81a369682ba7d56c38ce99418d047892b7ab85018d379
    Stored in directory: /home/django/.cache/pip/wheels/f4/87/b1/64ab49f2cc29e391daf42823b9f76c858fd9bcb43a28f3e8c8
    Successfully built environ Unipath
    Installing collected packages: typing-extensions, urllib3, toml, sqlparse, pytz, pycodestyle, pyasn1, idna, django-js-asset, charset-normalizer, certifi, asgiref, wincertstore, whitenoise, Unipath, six, rsa, requests, python-decouple, pyasn1-modules, protobuf, Pillow, gunicorn, environ, docutils, django-ckeditor, Django, dj-database-url, cachetools, autopep8
    
    Successfully installed Django-3.2.6 Pillow-8.3.2 Unipath-1.1 asgiref-3.4.1 autopep8-1.5.7 cachetools-4.2.4 certifi-2021.5.30 charset-normalizer-2.0.7 dj-database-url-0.5.0 django-ckeditor-6.1.0 django-js-asset-1.2.2 docutils-0.17.1 environ-1.0 gunicorn-20.1.0 idna-3.3 protobuf-3.19.0 pyasn1-0.4.8 pyasn1-modules-0.2.8 pycodestyle-2.7.0 python-decouple-3.4 pytz-2021.1 requests-2.26.0 rsa-4.7.2 six-1.16.0 sqlparse-0.4.2 toml-0.10.2 typing-extensions-4.0.0 urllib3-1.26.7 whitenoise-5.3.0 wincertstore-0.2
    
    (env) [django@localhost django]$
    

Leave a Reply