pipenv: AttributeError: 'NoneType' object has no attribute 'pythons' when creating new pipfile
Issue description
I tried to run pipenv install --verbose
and it failed.
Expected result
I expected a virtualenv to be set up, a pipfile to be created, and no errors to pop up.
Actual result (ran with --verbose
)
Creating a virtualenv for this project…
Pipfile: /Users/******/Pipfile
Using /usr/local/Cellar/pipenv/2018.11.26/libexec/bin/python3.7 (3.7.2) to create virtualenv…
⠏ Creating virtual environment...Already using interpreter /usr/local/Cellar/pipenv/2018.11.26/libexec/bin/python3.7
Using real prefix '/usr/local/Cellar/python/3.7.2/Frameworks/Python.framework/Versions/3.7'
New python executable in /Users/******/.local/share/virtualenvs/******/bin/python3.7
Also creating executable in /Users/******/.local/share/virtualenvs/******/bin/python
Installing setuptools, pip, wheel...
done.
✔ Successfully created virtual environment!
Virtualenv location: /Users/******/.local/share/virtualenvs/******/
Creating a Pipfile for this project…
Traceback (most recent call last):
File "/usr/local/Cellar/pipenv/2018.11.26/libexec/bin/pipenv", line 11, in <module>
load_entry_point('pipenv==2018.11.26', 'console_scripts', 'pipenv')()
File "/usr/local/Cellar/pipenv/2018.11.26/libexec/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 764, in __call__
return self.main(*args, **kwargs)
File "/usr/local/Cellar/pipenv/2018.11.26/libexec/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 717, in main
rv = self.invoke(ctx)
File "/usr/local/Cellar/pipenv/2018.11.26/libexec/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/Cellar/pipenv/2018.11.26/libexec/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/Cellar/pipenv/2018.11.26/libexec/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
File "/usr/local/Cellar/pipenv/2018.11.26/libexec/lib/python3.7/site-packages/pipenv/vendor/click/decorators.py", line 64, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "/usr/local/Cellar/pipenv/2018.11.26/libexec/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
File "/usr/local/Cellar/pipenv/2018.11.26/libexec/lib/python3.7/site-packages/pipenv/vendor/click/decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File "/usr/local/Cellar/pipenv/2018.11.26/libexec/lib/python3.7/site-packages/pipenv/cli/command.py", line 254, in install
editable_packages=state.installstate.editables,
File "/usr/local/Cellar/pipenv/2018.11.26/libexec/lib/python3.7/site-packages/pipenv/core.py", line 1741, in do_install
pypi_mirror=pypi_mirror,
File "/usr/local/Cellar/pipenv/2018.11.26/libexec/lib/python3.7/site-packages/pipenv/core.py", line 609, in ensure_project
validate=validate, skip_requirements=skip_requirements, system=system
File "/usr/local/Cellar/pipenv/2018.11.26/libexec/lib/python3.7/site-packages/pipenv/core.py", line 320, in ensure_pipfile
project.create_pipfile(python=python)
File "/usr/local/Cellar/pipenv/2018.11.26/libexec/lib/python3.7/site-packages/pipenv/project.py", line 726, in create_pipfile
required_python = self.which("python", self.virtualenv_location)
File "/usr/local/Cellar/pipenv/2018.11.26/libexec/lib/python3.7/site-packages/pipenv/project.py", line 1083, in which
result = next(iter(filter(None, (find(finder) for finder in self.finders))), None)
File "/usr/local/Cellar/pipenv/2018.11.26/libexec/lib/python3.7/site-packages/pipenv/project.py", line 1083, in <genexpr>
result = next(iter(filter(None, (find(finder) for finder in self.finders))), None)
File "/usr/local/Cellar/pipenv/2018.11.26/libexec/lib/python3.7/site-packages/pipenv/vendor/pythonfinder/pythonfinder.py", line 67, in which
return self.system_path.which(exe)
File "/usr/local/Cellar/pipenv/2018.11.26/libexec/lib/python3.7/site-packages/pipenv/vendor/pythonfinder/pythonfinder.py", line 54, in system_path
ignore_unsupported=self.ignore_unsupported,
File "/usr/local/Cellar/pipenv/2018.11.26/libexec/lib/python3.7/site-packages/pipenv/vendor/pythonfinder/models/path.py", line 451, in create
ignore_unsupported=ignore_unsupported,
File "<attrs generated init 75e45f144e3d5510d54dd5fca6730b98fa0220a9>", line 38, in __init__
File "/usr/local/Cellar/pipenv/2018.11.26/libexec/lib/python3.7/site-packages/pipenv/vendor/pythonfinder/models/path.py", line 116, in __attrs_post_init__
self._setup_pyenv()
File "/usr/local/Cellar/pipenv/2018.11.26/libexec/lib/python3.7/site-packages/pipenv/vendor/pythonfinder/models/path.py", line 196, in _setup_pyenv
version_glob_path="versions/*", ignore_unsupported=self.ignore_unsupported
File "/usr/local/Cellar/pipenv/2018.11.26/libexec/lib/python3.7/site-packages/pipenv/vendor/pythonfinder/models/python.py", line 156, in create
sort_function=sort_function, version_glob_path=version_glob_path)
File "<attrs generated init e10e89ae41c3b673beaf8c9439cf2f48dc63d342>", line 21, in __init__
File "/usr/local/Cellar/pipenv/2018.11.26/libexec/lib/python3.7/site-packages/pipenv/vendor/pythonfinder/models/python.py", line 147, in get_pythons
pythons.update(p.pythons)
AttributeError: 'NoneType' object has no attribute 'pythons'
Steps to replicate
Provide the steps to replicate (which usually at least includes the commands and the Pipfile).
pipenv install --verbose
on macOS with pyenv installed.
$ pipenv --support
Pipenv version: '2018.11.26'
Pipenv location: '/usr/local/Cellar/pipenv/2018.11.26/libexec/lib/python3.7/site-packages/pipenv'
Python location: '/usr/local/Cellar/pipenv/2018.11.26/libexec/bin/python3.7'
Python installations found:
Traceback (most recent call last):
File "/usr/local/Cellar/pipenv/2018.11.26/libexec/bin/pipenv", line 11, in <module>
load_entry_point('pipenv==2018.11.26', 'console_scripts', 'pipenv')()
File "/usr/local/Cellar/pipenv/2018.11.26/libexec/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 764, in __call__
return self.main(*args, **kwargs)
File "/usr/local/Cellar/pipenv/2018.11.26/libexec/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 717, in main
rv = self.invoke(ctx)
File "/usr/local/Cellar/pipenv/2018.11.26/libexec/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 1114, in invoke
return Command.invoke(self, ctx)
File "/usr/local/Cellar/pipenv/2018.11.26/libexec/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/Cellar/pipenv/2018.11.26/libexec/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
File "/usr/local/Cellar/pipenv/2018.11.26/libexec/lib/python3.7/site-packages/pipenv/vendor/click/decorators.py", line 64, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "/usr/local/Cellar/pipenv/2018.11.26/libexec/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
File "/usr/local/Cellar/pipenv/2018.11.26/libexec/lib/python3.7/site-packages/pipenv/vendor/click/decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File "/usr/local/Cellar/pipenv/2018.11.26/libexec/lib/python3.7/site-packages/pipenv/cli/command.py", line 146, in cli
get_pipenv_diagnostics()
File "/usr/local/Cellar/pipenv/2018.11.26/libexec/lib/python3.7/site-packages/pipenv/help.py", line 33, in get_pipenv_diagnostics
python_paths = finder.find_all_python_versions()
File "/usr/local/Cellar/pipenv/2018.11.26/libexec/lib/python3.7/site-packages/pipenv/vendor/pythonfinder/pythonfinder.py", line 122, in find_all_python_versions
python_version_dict = getattr(self.system_path, "python_version_dict")
File "/usr/local/Cellar/pipenv/2018.11.26/libexec/lib/python3.7/site-packages/pipenv/vendor/pythonfinder/pythonfinder.py", line 54, in system_path
ignore_unsupported=self.ignore_unsupported,
File "/usr/local/Cellar/pipenv/2018.11.26/libexec/lib/python3.7/site-packages/pipenv/vendor/pythonfinder/models/path.py", line 451, in create
ignore_unsupported=ignore_unsupported,
File "<attrs generated init 75e45f144e3d5510d54dd5fca6730b98fa0220a9>", line 38, in __init__
File "/usr/local/Cellar/pipenv/2018.11.26/libexec/lib/python3.7/site-packages/pipenv/vendor/pythonfinder/models/path.py", line 116, in __attrs_post_init__
self._setup_pyenv()
File "/usr/local/Cellar/pipenv/2018.11.26/libexec/lib/python3.7/site-packages/pipenv/vendor/pythonfinder/models/path.py", line 196, in _setup_pyenv
version_glob_path="versions/*", ignore_unsupported=self.ignore_unsupported
File "/usr/local/Cellar/pipenv/2018.11.26/libexec/lib/python3.7/site-packages/pipenv/vendor/pythonfinder/models/python.py", line 156, in create
sort_function=sort_function, version_glob_path=version_glob_path)
File "<attrs generated init bc0428324c02997e1f41dd7925001d6ab66b13b8>", line 21, in __init__
File "/usr/local/Cellar/pipenv/2018.11.26/libexec/lib/python3.7/site-packages/pipenv/vendor/pythonfinder/models/python.py", line 147, in get_pythons
pythons.update(p.pythons)
AttributeError: 'NoneType' object has no attribute 'pythons'
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 4
- Comments: 20 (2 by maintainers)
Had a similar issue and the problem for me was that macOS had created a
.DS_Store
file in theversions
folder for pyenv, which Pipfile was choking on. A quick workaround is to simply remove that file, soSorry I have one more update: I changed the pipenv command and managed to get things working again! What I was doing before:
pyenv global 3.7.2
pipenv install
= Failpyenv global 3.7.2
pipenv install --python=~/.pyenv/versions/3.7.2/bin/python
= Failpyenv global 3.7.2
pipenv install --python=/Users/Will/.pyenv/versions/3.7.2/bin/python
= Success! pythonfinder does not appear to like the tilde path perhaps?In case anybody winds up here from Google, I had this issue and the reason was a symlink in my
.pyenv/versions
folder. Upon removal of the symlink all was well.It appears that plonking anything other than exactly what pyenv expects in the
versions
dir causes unexpected behavior. 😃I ran into this even though my
~/.pyenv/versions
folder looked just fine at first glance. Following the suggestions in this thread I dug a bit more and found that one of my python versions was missing abin/
folder inside it, probably a botched install; removing that folder/install fixed my pipenv issues.p.s. the way I figured out something was wrong with that particular version (it wasn’t the version I was trying to use btw) was that the
3.6.3
folder was slightly smaller than all the other ones, and upon inspection the corruption became obviousIn my case, I had a zip file in the
.pyenv/versions/
directory (long story: my compiler is broken on one machine, so I have to copy new python versions across).Removing the zip file(s) means it works.
to those struggling with this issue – can you confirm whether it is resolved using the prelease version? You can install the prerelease via
pip install --upgrade --pre pipenv
The vendored
pythonfinder
package has a bug in it: https://github.com/sarugaku/pythonfinder/issues/79I got things working by patching
pythonfinder
. I’ve written more in that ticket, including what I did to workaround the bug. It might not work for all situations though.getting this error below when running:
pipenv --python 3.7.4
where python 3.7.4 is the global python set so by pyenv
from the above it sounds like this should either have already been resolved, or is due to symlinks in the .pyenv/versions/X.X.X/bin/ directory
I re-installed everything, i.e. pyenv, virtualenv, and pipenv today and the issue is still coming up. So it’s not due to an older version.
got it to work by setting the python version explicitly by path:
pipenv --python ~/.pyenv/versions/3.7.4/bin/python3.7