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

AttributeError: 'NoneType' object has no attribute 'version_sort' #4296

Closed
SentinelWarren opened this issue May 30, 2020 · 29 comments · Fixed by #4302
Closed

AttributeError: 'NoneType' object has no attribute 'version_sort' #4296

SentinelWarren opened this issue May 30, 2020 · 29 comments · Fixed by #4302
Labels
Type: Bug 🐛 This issue is a bug. Type: Vendored Dependencies This issue affects vendored dependencies within pipenv.

Comments

@SentinelWarren
Copy link

Issue description

Running pipenv install --verbose failed.

Expected result

Expected a virtual env to be set up, a pipfile created, and no errors to pop up.

Actual result


Traceback (most recent call last):
  File "c:\python38\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\python38\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Python38\Scripts\pipenv.exe\__main__.py", line 7, in <module>
  File "C:\Python38\Lib\site-packages\pipenv\vendor\click\core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "C:\Python38\Lib\site-packages\pipenv\vendor\click\core.py", line 782, in main
    rv = self.invoke(ctx)
  File "C:\Python38\Lib\site-packages\pipenv\vendor\click\core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Python38\Lib\site-packages\pipenv\vendor\click\core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Python38\Lib\site-packages\pipenv\vendor\click\core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "C:\Python38\Lib\site-packages\pipenv\vendor\click\decorators.py", line 73, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "C:\Python38\Lib\site-packages\pipenv\vendor\click\core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "C:\Python38\Lib\site-packages\pipenv\vendor\click\decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "c:\python38\lib\site-packages\pipenv\cli\command.py", line 231, in install
    retcode = do_install(
  File "c:\python38\lib\site-packages\pipenv\core.py", line 1924, in do_install
    ensure_project(
  File "c:\python38\lib\site-packages\pipenv\core.py", line 581, in ensure_project
    ensure_virtualenv(
  File "c:\python38\lib\site-packages\pipenv\core.py", line 495, in ensure_virtualenv
    python = ensure_python(three=three, python=python)
  File "c:\python38\lib\site-packages\pipenv\core.py", line 385, in ensure_python
    path_to_python = find_a_system_python(python)
  File "c:\python38\lib\site-packages\pipenv\core.py", line 347, in find_a_system_python
    return next(iter(finder.find_all_python_versions()), None)
  File "c:\python38\lib\site-packages\pipenv\vendor\pythonfinder\pythonfinder.py", line 328, in find_all_python_versions
    path_list = sorted(versions, key=version_sort, reverse=True)
AttributeError: 'NoneType' object has no attribute 'version_sort'

Steps to replicate

Provide the steps to replicate (which usually at least includes the commands and the Pipfile).

pipenv install --verbose on win10 machine.

$ pipenv --support

Pipenv version: '2020.5.28'

Pipenv location: 'c:\\python38\\lib\\site-packages\\pipenv'

Python location: 'c:\\python38\\python.exe'

Python installations found:

Traceback (most recent call last):
  File "c:\python38\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\python38\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Python38\Scripts\pipenv.exe\__main__.py", line 7, in <module>
  File "C:\Python38\Lib\site-packages\pipenv\vendor\click\core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "C:\Python38\Lib\site-packages\pipenv\vendor\click\core.py", line 782, in main
    rv = self.invoke(ctx)
  File "C:\Python38\Lib\site-packages\pipenv\vendor\click\core.py", line 1236, in invoke
    return Command.invoke(self, ctx)
  File "C:\Python38\Lib\site-packages\pipenv\vendor\click\core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Python38\Lib\site-packages\pipenv\vendor\click\core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "C:\Python38\Lib\site-packages\pipenv\vendor\click\decorators.py", line 73, in new_func    
    return ctx.invoke(f, obj, *args, **kwargs)
  File "C:\Python38\Lib\site-packages\pipenv\vendor\click\core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "C:\Python38\Lib\site-packages\pipenv\vendor\click\decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "c:\python38\lib\site-packages\pipenv\cli\command.py", line 138, in cli
    get_pipenv_diagnostics()
  File "c:\python38\lib\site-packages\pipenv\help.py", line 33, in get_pipenv_diagnostics
    python_paths = finder.find_all_python_versions()
  File "c:\python38\lib\site-packages\pipenv\vendor\pythonfinder\pythonfinder.py", line 328, in find_all_python_versions
    path_list = sorted(versions, key=version_sort, reverse=True)
AttributeError: 'NoneType' object has no attribute 'version_sort'
@jasoncammarata
Copy link

I'm getting the same error. Looking forward to someone smarter finding a resolution

@jasoncammarata
Copy link

I found a workaround, but I'm not good enough with computers/python/virtual environments to know why it works.
From Terminal:

  1. Download virtualenv (if your pip install of pipenv didn't already)
  2. Create a virtual environment in virtualenv --> look online for instructions
  3. once inside the virtualenv go to the folder you want your pipfile
  4. pipenv install [python_package]
  5. Should create the pipfile and lock files. Then exit the virtual environment
  6. Navigate to the folder for your project with pipenv files
  7. type pipenv shell. This should create a virtual environment within the pipenv construct.

@frostming frostming added Type: Bug 🐛 This issue is a bug. Type: Vendored Dependencies This issue affects vendored dependencies within pipenv. labels Jun 1, 2020
@triage-new-issues triage-new-issues bot removed the triage label Jun 1, 2020
@frostming frostming added this to the 2020.6.x bugfix release milestone Jun 1, 2020
@frostming frostming mentioned this issue Jun 1, 2020
2 tasks
@roshansivakumar
Copy link

roshansivakumar commented Jun 13, 2020

i've got the same error, anything to resolve it?
Though pipenv install in a created virtaulenv works with no issues like jasoncammarata mentioned.
Why is that?

@vincentclaes
Copy link

this issue still persists on win10 with python 3.8.3 and pipenv 2020.6.2

DVCL643@10NB03610:~/workspace/python/mailswitch_security$ pipenv shell
Traceback (most recent call last):
  File "c:\users\dvcl643\appdata\local\programs\python\python38\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\users\dvcl643\appdata\local\programs\python\python38\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\dvcl643\AppData\Local\Programs\Python\Python38\Scripts\pipenv.exe\__main__.py", line 9, in <module>
  File "C:\Users\dvcl643\AppData\Local\Programs\Python\Python38\Lib\site-packages\pipenv\vendor\click\core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\dvcl643\AppData\Local\Programs\Python\Python38\Lib\site-packages\pipenv\vendor\click\core.py", line 782, in main
    rv = self.invoke(ctx)
  File "C:\Users\dvcl643\AppData\Local\Programs\Python\Python38\Lib\site-packages\pipenv\vendor\click\core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Users\dvcl643\AppData\Local\Programs\Python\Python38\Lib\site-packages\pipenv\vendor\click\core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\dvcl643\AppData\Local\Programs\Python\Python38\Lib\site-packages\pipenv\vendor\click\core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "C:\Users\dvcl643\AppData\Local\Programs\Python\Python38\Lib\site-packages\pipenv\vendor\click\decorators.py", line 73, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "C:\Users\dvcl643\AppData\Local\Programs\Python\Python38\Lib\site-packages\pipenv\vendor\click\core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "c:\users\dvcl643\appdata\local\programs\python\python38\lib\site-packages\pipenv\cli\command.py", line 428, in shell
    do_shell(
  File "c:\users\dvcl643\appdata\local\programs\python\python38\lib\site-packages\pipenv\core.py", line 2363, in do_shell
    ensure_project(
  File "c:\users\dvcl643\appdata\local\programs\python\python38\lib\site-packages\pipenv\core.py", line 576, in ensure_project
    ensure_virtualenv(
  File "c:\users\dvcl643\appdata\local\programs\python\python38\lib\site-packages\pipenv\core.py", line 498, in ensure_virtualenv
    python = ensure_python(three=three, python=python)
  File "c:\users\dvcl643\appdata\local\programs\python\python38\lib\site-packages\pipenv\core.py", line 388, in ensure_python
    path_to_python = find_a_system_python(python)
  File "c:\users\dvcl643\appdata\local\programs\python\python38\lib\site-packages\pipenv\core.py", line 350, in find_a_system_python
    return next(iter(finder.find_all_python_versions()), None)
  File "c:\users\dvcl643\appdata\local\programs\python\python38\lib\site-packages\pipenv\vendor\pythonfinder\pythonfinder.py", line 328, in find_all_python_ve
rsions
    path_list = sorted(versions, key=version_sort, reverse=True)
AttributeError: 'NoneType' object has no attribute 'version_sort'

I have solved this by reverting to

pip install pipenv==2018.11.26

@madnoh
Copy link

madnoh commented Jul 12, 2020

Windows 10, Python 3.8.3, pipenv 2020.6.2

I managed to solve this by typing in the full path to the python.exe:

pipenv install --python="C:\Users\my_name\AppData\Local\Programs\Python\Python38\python.exe"

Viola! Virtual environment created.

@leehanchung
Copy link

Still getting the same error with full path to python.exe.

Windows 10, Build 20161
Miniconda Python 3.7.4
pipenv 2020.6.2

pipenv install --python="C:\Users\Han\Miniconda3\python.exe"

Pipfile:

[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]
pytest = "*"
v = {editable = true,version = "*"}

[packages]
numpy = "==1.19"
tensorflow = "==2.2"
pillow = "*"
requests = "*"
nltk = "*"
matplotlib = "*"

[requires]
python_version = "3.7"

@Insigna2020
Copy link

Insigna2020 commented Jul 24, 2020

I ended up having to specify Python version on pipfile in order to work with 3.8

[requires]
python_version = "3.8"

@vijay532
Copy link

where is pipfile located ?

@vijay532
Copy link

where is pipfile located ?

@vincentclaes thanks issues has been solved..

@mracette
Copy link

mracette commented Aug 19, 2020

I am also seeing this error on OSX 10.14.6, with pipenv 2020.8.13:

Pipfile:

[requires]
python_version = "3.7.6"

pipenv install --dev --python $(pyenv root)/versions/3.7.6/bin/python

Finally,
AttributeError: 'NoneType' object has no attribute 'url'

@sigtot
Copy link

sigtot commented Aug 25, 2020

Did you ever find a solution to this @mracette ?

Edit: I had mracette's exact same error message, but was able to resolve it by reverting to pipenv==2018.11.26. It appeared in version pipenv==2020.4.1b1 which is the first release after the 2018 one.

@mracette
Copy link

@sigtot I also had to revert to 2018.11.26

@ryanjdillon
Copy link

@sigtot pip-tools and run of-the-mill venv? 😄

@Zalarian
Copy link

Zalarian commented Oct 2, 2020

I am getting this too. Is there any specific reason as to why this is happening? Does it use the PATH / PYTHONPATH env variable?

I had multiple versions of python installed, along with trying out chocolatey and this error just appeared one day. Probably after I upgraded it. I went through, uninstalled every listed version of python, reinstalled 3.8.6 at system-level and still got this error. Uninstalled that and used chocolatey to install 3.8.6 and, yet again, still popped up.

I'm not sure if somehow my environment variables got messed up with the multiple versions and chocolatey, but I thought it would have been fixed with an uninstall/reinstall.

@gaochuwuhan
Copy link

I also got that error!!! Centos enviroment makes no sense as well.. have tried 2 computers under pipenv&pyenv,same message

@dixanms
Copy link

dixanms commented Oct 11, 2020

as others have stated, resolved downgrading to pipenv 2018.11.26_4

@ArunSharma93
Copy link

Running pip3 install pipenv==2018.11.26 in terminal solved the below issue for me

AttributeError: 'NoneType' object has no attribute 'url'

@PatrikWiklund
Copy link

I went in to "pythonfinder.py" where the error occurs, and commented out the sorting of the python version list. Felt comfortable doing it because of the comment.

So from:
# This list has already been mostly sorted on windows, we don't need to reverse it again path_list = sorted(versions, key=version_sort, reverse=True)

to:
# This list has already been mostly sorted on windows, we don't need to reverse it again # path_list = sorted(versions, key=version_sort, reverse=True) path_list = versions

This solved it for me.

@Systemcluster
Copy link

@PatrikWiklund I created a PR to filter out None results before the sorted call as well.

@Cosmicoppai
Copy link

I went in to "pythonfinder.py" where the error occurs, and commented out the sorting of the python version list. Felt comfortable doing it because of the comment.

So from:
# This list has already been mostly sorted on windows, we don't need to reverse it again path_list = sorted(versions, key=version_sort, reverse=True)

to:
# This list has already been mostly sorted on windows, we don't need to reverse it again # path_list = sorted(versions, key=version_sort, reverse=True) path_list = versions

This solved it for me.

After implementing above solution, I'm getting the Value Error "Unable to find t64.exe in package distlib"(despite the existence of t64.exe)

@JadJabbour
Copy link

run it with "--three"

pipenv --three

@azmek
Copy link

azmek commented Apr 10, 2021

run it with "--three"

pipenv --three

Thanks JadJabbour
This worked for me
ex: pipenv --three install django~=3.1.0

@DeepSpace2
Copy link

DeepSpace2 commented May 21, 2021

Still happening with latest versions of pip and pipenv?

$ python38 -m pip --version
pip 21.1.1 from D:\Python38\lib\site-packages\pip (python 3.8)
 $ python38 -m pip freeze | grep pipenv
pipenv==2020.11.15
$ python38 -m pipenv install rich
Traceback (most recent call last):
  File "D:\Python38\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "D:\Python38\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "D:\Python38\lib\site-packages\pipenv\__main__.py", line 5, in <module>
    cli()
  File "D:\Python38\Lib\site-packages\pipenv\vendor\click\core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "D:\Python38\Lib\site-packages\pipenv\vendor\click\core.py", line 782, in main
    rv = self.invoke(ctx)
  File "D:\Python38\Lib\site-packages\pipenv\vendor\click\core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "D:\Python38\Lib\site-packages\pipenv\vendor\click\core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "D:\Python38\Lib\site-packages\pipenv\vendor\click\core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "D:\Python38\Lib\site-packages\pipenv\vendor\click\decorators.py", line 73, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "D:\Python38\Lib\site-packages\pipenv\vendor\click\core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "D:\Python38\Lib\site-packages\pipenv\vendor\click\decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "D:\Python38\lib\site-packages\pipenv\cli\command.py", line 233, in install
    retcode = do_install(
  File "D:\Python38\lib\site-packages\pipenv\core.py", line 1920, in do_install
    ensure_project(
  File "D:\Python38\lib\site-packages\pipenv\core.py", line 576, in ensure_project
    ensure_virtualenv(
  File "D:\Python38\lib\site-packages\pipenv\core.py", line 498, in ensure_virtualenv
    python = ensure_python(three=three, python=python)
  File "D:\Python38\lib\site-packages\pipenv\core.py", line 388, in ensure_python
    path_to_python = find_a_system_python(python)
  File "D:\Python38\lib\site-packages\pipenv\core.py", line 350, in find_a_system_python
    return next(iter(finder.find_all_python_versions()), None)
  File "D:\Python38\lib\site-packages\pipenv\vendor\pythonfinder\pythonfinder.py", line 328, in find_all_python_versions
    path_list = sorted(versions, key=version_sort, reverse=True)
AttributeError: 'NoneType' object has no attribute 'version_sort'

@johnfawzy84
Copy link

Running pip3 install pipenv==2018.11.26 in terminal solved the below issue for me

AttributeError: 'NoneType' object has no attribute 'url'

this is solution is a life saver

@screwt
Copy link

screwt commented Jun 22, 2021

Same error on win10 pipenv==2021.5.29 installing 2018.11.26 makes pipenv work as expected.

@R30B
Copy link

R30B commented Jun 25, 2021

Same error i encountered but when i used pipenv --python 3.8 it worked.I hope it helps....

@kevillion
Copy link

Workaround for pipenv 2021.5.29:
specify your version of python when running pipenv for the first time:

pipenv --python 3.9.5
pipenv install

If you don't know your version of python:
python --version

All previous versions of pipenv appear to run as expected.

@EudesSerpa
Copy link

I solved it by adding: C:\Users\Username\AppData\Roaming\Python38\Scripts and C:\Users\Username\AppData\Roaming\Python38\site-package to environment variables.

@georgik
Copy link

georgik commented Nov 3, 2021

The issue is still present in Windows Python 3.9.7 installed from Microsoft Store, pipenv, version 2021.5.29
@kevillion workaround solved the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug 🐛 This issue is a bug. Type: Vendored Dependencies This issue affects vendored dependencies within pipenv.
Projects
None yet
Development

Successfully merging a pull request may close this issue.