Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jeremyje opened this issue Sep 27, 2018 · 31 comments
Labels
auto-locked Outdated issues that have been locked by automation type: support User Support

Comments

@jeremyje
Copy link

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.
@pfmoore
Copy link
Member

pfmoore commented Sep 27, 2018

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).

@fingerman
Copy link

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

@WeatherGod
Copy link

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'

@WeatherGod
Copy link

Ah, I didn't look closely enough at the tracebacks, shall I file a new bug report?

@benoit-pierre
Copy link
Member

@WeatherGod: that's not the same issue, check the discussion around this comment: #5571 (review).

@WeatherGod
Copy link

Ah, indeed, shall I add my traceback there?

@benoit-pierre
Copy link
Member

Better to open a new bug, so the issue can be properly tracked.

@Overdrivr
Copy link

Fix from @fingerman not working in my case. Installation is broken, any idea about what is going on ?

@maximlion
Copy link

Still happening.

@yokasre
Copy link

yokasre commented Nov 22, 2018

@fingerman Thanks. That worked instantly.

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

@mykelismyname
Copy link

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

@augustz
Copy link

augustz commented Dec 1, 2018

@fingerman Thanks

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

works

@pradyunsg pradyunsg added the S: needs triage Issues/PRs that need to be triaged label Dec 14, 2018
@hemangjoshi37a
Copy link

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

@conradogarciaberrotaran

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

@CrazyEoin
Copy link

@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.

@sensoumya
Copy link

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

@HansBouwmeester
Copy link

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.

@tjnh05
Copy link

tjnh05 commented Feb 11, 2019

easy_install -U pip
The command above is good!

@AndCycle
Copy link

AndCycle commented Feb 12, 2019

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.)

@indrasishg
Copy link

python -m pip install -U --force-reinstall pip
worked for me

@Hameem1
Copy link

Hameem1 commented Mar 5, 2019

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

@sapien47
Copy link

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

@fingerman
Copy link

fingerman commented Mar 17, 2019

@sapien47 #5820 (comment)

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

@den200x
Copy link

den200x commented Mar 28, 2019

@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.

THANK YOU! this damn problem has been bugging me for the past hour, would you mind how you came across this fantastic solution? i will go learn about wth an .egg is

@mph-code
Copy link

mph-code commented May 4, 2019

easy_install -U pip worked for me. thank you!

@thisisreallife
Copy link

thisisreallife commented May 22, 2019

I use jupyter notebook with py3.6 on win10. The problem still exists when I upgrade pip from 19.0.3 to 19.1.1.

Here is my sys.path:

['',
 'C:\\ProgramData\\Anaconda3\\python36.zip',
 'C:\\ProgramData\\Anaconda3\\DLLs',
 'C:\\ProgramData\\Anaconda3\\lib',
 'C:\\ProgramData\\Anaconda3',
 'C:\\Users\\SSQ\\AppData\\Roaming\\Python\\Python36\\site-packages',
 'C:\\ProgramData\\Anaconda3\\lib\\site-packages',
 'C:\\ProgramData\\Anaconda3\\lib\\site-packages\\Sphinx-1.5.6-py3.6.egg',
 'C:\\ProgramData\\Anaconda3\\lib\\site-packages\\win32',
 'C:\\ProgramData\\Anaconda3\\lib\\site-packages\\win32\\lib',
 'C:\\ProgramData\\Anaconda3\\lib\\site-packages\\Pythonwin',
 'C:\\ProgramData\\Anaconda3\\lib\\site-packages\\IPython\\extensions',
 'C:\\Users\\SSQ\\.ipython']

However, easy_install -U pip did work. Thx!

@shyamrallapalli
Copy link

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.)

This seems to be the case for my error as well.
Use pip list --user to find if pip is installed at user level
where pip on windows lists full path of where pip binaries are

@zwep
Copy link

zwep commented Jun 20, 2019

Still happening while using Python 3.6, Windows 10, going from pip 10.0.1 to 19.1.1

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

did fix it for me.

@eapazavil
Copy link

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

thanks bro

@deb991
Copy link

deb991 commented Jun 28, 2019

python -m pip install -U --force-reinstall pip
worked for me, while I was upgrading from 18.1 to 19.1.1
Thanks for your help & sorry for my bad English.

@pradyunsg
Copy link
Member

Closing since we have a resolution on this.

@pradyunsg pradyunsg added type: support User Support and removed S: needs triage Issues/PRs that need to be triaged labels Jun 29, 2019
@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Jul 29, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jul 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation type: support User Support
Projects
None yet
Development

No branches or pull requests