pip: pip 18.0 install fails with AttributeError: 'NoneType' object has no attribute 'bytes'

Environment

  • pip version: 10.0.1 -> 18.0
  • Python version: 3.7 (Windows x64)
  • OS: Windows 10

Description pip installs with a compile at runtime bug.

Expected behavior pip installs without error.

How to Reproduce

  1. Download python 3.7 for windows x64. https://www.python.org/ftp/python/3.7.1/python-3.7.1rc1-amd64.exe
  2. Install the package
  3. Install PyCharm 2018.02
  4. Create a new PyCharm project with virtualenv.
  5. Create a new terminal and update pip

Output You are using pip version 10.0.1, however version 18.0 is available. You should consider upgrading via the ‘python -m pip install --upgrade pip’ command.

(venv) C:\projects\nltk-tutorial>python -m pip install --upgrade pip Collecting pip Downloading https://files.pythonhosted.org/packages/5f/25/e52d3f31441505a5f3af41213346e5b6c221c9e086a166f3703d2ddaf940/pip-18.0-py2.py3-none-any.whl (1.3MB) 100% |████████████████████████████████| 1.3MB 5.8MB/s Installing collected packages: pip Found existing installation: pip 10.0.1 Uninstalling pip-10.0.1: Successfully uninstalled pip-10.0.1 Rolling back uninstall of pip Exception: Traceback (most recent call last): File “C:\projects\nltk-tutorial\venv\lib\site-packages\pip-10.0.1-py3.7.egg\pip_internal\basecommand.py”, line 228, in main status = self.run(options, args) File “C:\projects\nltk-tutorial\venv\lib\site-packages\pip-10.0.1-py3.7.egg\pip_internal\commands\install.py”, line 335, in run use_user_site=options.use_user_site, File “C:\projects\nltk-tutorial\venv\lib\site-packages\pip-10.0.1-py3.7.egg\pip_internal\req_init_.py”, line 49, in install_given_reqs **kwargs File “C:\projects\nltk-tutorial\venv\lib\site-packages\pip-10.0.1-py3.7.egg\pip_internal\req\req_install.py”, line 748, in install use_user_site=use_user_site, pycompile=pycompile, File “C:\projects\nltk-tutorial\venv\lib\site-packages\pip-10.0.1-py3.7.egg\pip_internal\req\req_install.py”, line 961, in move_wheel_files warn_script_location=warn_script_location, File “C:\projects\nltk-tutorial\venv\lib\site-packages\pip-10.0.1-py3.7.egg\pip_internal\wheel.py”, line 431, in move_wheel_files generated.extend(maker.make(spec)) File “C:\projects\nltk-tutorial\venv\lib\site-packages\pip-10.0.1-py3.7.egg\pip_vendor\distlib\scripts.py”, line 403, in make self._make_script(entry, filenames, options=options) File “C:\projects\nltk-tutorial\venv\lib\site-packages\pip-10.0.1-py3.7.egg\pip_vendor\distlib\scripts.py”, line 307, in _make_script self._write_script(scriptnames, shebang, script, filenames, ext) File “C:\projects\nltk-tutorial\venv\lib\site-packages\pip-10.0.1-py3.7.egg\pip_vendor\distlib\scripts.py”, line 243, in _write_script launcher = self._get_launcher(‘t’) File “C:\projects\nltk-tutorial\venv\lib\site-packages\pip-10.0.1-py3.7.egg\pip_vendor\distlib\scripts.py”, line 382, in _get_launcher result = finder(distlib_package).find(name).bytes AttributeError: ‘NoneType’ object has no attribute ‘bytes’

(venv) C:\projects\nltk-tutorial>python -m pip install --upgrade pip Requirement already up-to-date: pip in c:\projects\nltk-tutorial\venv\lib\site-packages (18.0)

(venv) C:\projects\nltk-tutorial>pip install ERROR: You must give at least one requirement to install (see “pip help install”) You are using pip version 10.0.1, however version 18.0 is available. You should consider upgrading via the ‘python -m pip install --upgrade pip’ command.

Paste the output of the steps above, including the commands themselves and
pip's output/traceback etc.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 13
  • Comments: 31 (4 by maintainers)

Most upvoted comments

try: python -m pip install -U --force-reinstall pip inside your venv

@fingerman Thanks

python -m pip install -U --force-reinstall pip

works

@fingerman Thanks. That worked instantly.

python -m pip install -U --force-reinstall pip

PyCharm installs pip as an egg (see C:\projects\nltk-tutorial\venv\lib\site-packages\pip-10.0.1-py3.7.egg in the traceback above) and egg installations are not supported by pip (we can’t upgrade egg-layout installs).

You need to raise this with JetBrains, or create your environments manually. I believe there’s an existing issue about this on the PyCharm tracker (I raised one a couple of years ago, but haven’t heard anything about it since - I stopped tracking it when I gave up using PyCharm because this issue was too much of a problem for me).

easy_install -U pip worked for me. Was having the issue for 19.0.1

You might need the easy install, as it worked for me when upgrading my Pip easy_install -U pip Check this https://stackoverflow.com/questions/52460484/python-3-5-pip-9-attributeerror-nonetype-object-has-no-attribute-bytes

easy_install -U pip The command above is good!

ok, I just encounter the same issue but I have some basic info about this,

the old pip is actually inside my --user, so C:\Python37\python.exe -m pip install --user --force-reinstall -U pip works in my case if I didn’t instruct with --user the failure will occur

manual remove old version of pip in my user install directory also works,

--user Install to the Python user install directory for your platform. 
Typically ~/.local/, or %APPDATA%\Python on Windows. 
(See the Python documentation for site.USER_BASE for full details.)

@fingerman having the same issue on pip 19.0.1, any other fix? Thanks

I had the same but MichealAbaho from the above comment with the easy_install -U pip command fixed the issue for me.

“python -m pip install -U --force-reinstall pip” didn’t work but “easy_install -U pip” does the trick for me. Thanks a lot.

Same for me. python -m pip install -U --force-reinstall pip didn’t fix the problem where easy_install -U pip did. Also on 19.0.1.

@fingerman having the same issue on pip 19.0.1, any other fix? Thanks

@fingerman having same error for force install. Please help.

easy_install -U pip worked for me. thank you!

@sapien47 https://github.com/pypa/pip/issues/5820#issuecomment-473693608

import sys
import pprint
pprint.pprint(sys.path)

This shows where python is looking for python files. It can be useful when you try to troubleshoot python import errors

Nothing worked for me, I eventually installed a coexisting version of Python (3.7), and pip could be upgrdaed for that version.

I am having a similar problem (at least, the traceback is similar). I am using a fresh conda environment (most packages from conda-forge), pip 18.1, python 3.6, and linux. The force-reinstall command given does not solve my issue. I am utilizing the new PEP508 syntax for installing private packages from our internal gitlab server (anonymized below). I added some print statements that I hope will be helpful:

$ pip install -e .
Obtaining file:///nas/home/broot/Programs/tools/catutils
req: shapely
comes_from: catutils==0.15.dev1 from file:///nas/home/broot/Programs/tools/catutils
req: netCDF4
comes_from: catutils==0.15.dev1 from file:///nas/home/broot/Programs/tools/catutils
req: aershp>=0.10
comes_from: catutils==0.15.dev1 from file:///nas/home/broot/Programs/tools/catutils
req: numpy!=1.10,!=1.11.0
comes_from: catutils==0.15.dev1 from file:///nas/home/broot/Programs/tools/catutils
req: scipy
comes_from: catutils==0.15.dev1 from file:///nas/home/broot/Programs/tools/catutils
req: GDAL
comes_from: catutils==0.15.dev1 from file:///nas/home/broot/Programs/tools/catutils
Requirement already satisfied: shapely in /rd22/scratch/broot/miniconda/envs/py3k/lib/python3.6/site-packages (from catutils==0.15.dev1) (1.6.4.post1)
Requirement already satisfied: netCDF4 in /rd22/scratch/broot/miniconda/envs/py3k/lib/python3.6/site-packages (from catutils==0.15.dev1) (1.4.1)
req: numpy>=1.7
comes_from: netCDF4 in /rd22/scratch/broot/miniconda/envs/py3k/lib/python3.6/site-packages (from catutils==0.15.dev1)
req: cftime
comes_from: netCDF4 in /rd22/scratch/broot/miniconda/envs/py3k/lib/python3.6/site-packages (from catutils==0.15.dev1)
Requirement already satisfied: aershp>=0.10 in /nas/home/broot/Programs/tools/aershp/lib (from catutils==0.15.dev1) (0.16.dev1)
req: nose
comes_from: aershp>=0.10 in /nas/home/broot/Programs/tools/aershp/lib (from catutils==0.15.dev1)
req: numpy
comes_from: aershp>=0.10 in /nas/home/broot/Programs/tools/aershp/lib (from catutils==0.15.dev1)
req: matplotlib<2.2.0
comes_from: aershp>=0.10 in /nas/home/broot/Programs/tools/aershp/lib (from catutils==0.15.dev1)
req: Shapely
comes_from: aershp>=0.10 in /nas/home/broot/Programs/tools/aershp/lib (from catutils==0.15.dev1)
req: GDAL
comes_from: aershp>=0.10 in /nas/home/broot/Programs/tools/aershp/lib (from catutils==0.15.dev1)
req: pyyaml
comes_from: aershp>=0.10 in /nas/home/broot/Programs/tools/aershp/lib (from catutils==0.15.dev1)
req: jinja2
comes_from: aershp>=0.10 in /nas/home/broot/Programs/tools/aershp/lib (from catutils==0.15.dev1)
req: scripttest
comes_from: aershp>=0.10 in /nas/home/broot/Programs/tools/aershp/lib (from catutils==0.15.dev1)
req: netCDF4
comes_from: aershp>=0.10 in /nas/home/broot/Programs/tools/aershp/lib (from catutils==0.15.dev1)
req: six
comes_from: aershp>=0.10 in /nas/home/broot/Programs/tools/aershp/lib (from catutils==0.15.dev1)
req: atomic_context@ git+ssh://git@***********.com/common/atomic_context.git@release
comes_from: aershp>=0.10 in /nas/home/broot/Programs/tools/aershp/lib (from catutils==0.15.dev1)
Exception:
Traceback (most recent call last):
  File "/home/broot/scratch/miniconda/envs/py3k/lib/python3.6/site-packages/pip/_internal/cli/base_command.py", line 143, in main
    status = self.run(options, args)
  File "/home/broot/scratch/miniconda/envs/py3k/lib/python3.6/site-packages/pip/_internal/commands/install.py", line 318, in run
    resolver.resolve(requirement_set)
  File "/home/broot/scratch/miniconda/envs/py3k/lib/python3.6/site-packages/pip/_internal/resolve.py", line 102, in resolve
    self._resolve_one(requirement_set, req)
  File "/home/broot/scratch/miniconda/envs/py3k/lib/python3.6/site-packages/pip/_internal/resolve.py", line 318, in _resolve_one
    add_req(subreq, extras_requested=available_requested)
  File "/home/broot/scratch/miniconda/envs/py3k/lib/python3.6/site-packages/pip/_internal/resolve.py", line 275, in add_req
    wheel_cache=self.wheel_cache,
  File "/home/broot/scratch/miniconda/envs/py3k/lib/python3.6/site-packages/pip/_internal/req/constructors.py", line 290, in install_req_from_req
    if req.url and comes_from.link.netloc in domains_not_allowed:
AttributeError: 'NoneType' object has no attribute 'netloc'