Provide better error message if the project’s virtual environment is broken
See original GitHub issueWas: “Your Pipfile requires python_version 3.6, but you are using None” and various errors
I run pipenv, installed via brew install pipenv
on macOS 10.12. I’ve installed python
from Homebrew (3.6.5), as well as python@2
.
When I open pipenv shell
, I get this output:
➜ pipenv shell
Warning: Your Pipfile requires python_version 3.6, but you are using None (/Users/werner/.local/share/v/b/bin/python).
$ pipenv check will surely fail.
Spawning environment shell (/bin/zsh). Use 'exit' to leave.
When I run pipenv check
, I get:
Checking PEP 508 requirements…
Traceback (most recent call last):
File "/usr/local/Cellar/pipenv/11.9.0_1/libexec/bin/pipenv", line 11, in <module>
load_entry_point('pipenv==11.9.0', 'console_scripts', 'pipenv')()
File "/usr/local/Cellar/pipenv/11.9.0_1/libexec/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/usr/local/Cellar/pipenv/11.9.0_1/libexec/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/usr/local/Cellar/pipenv/11.9.0_1/libexec/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/Cellar/pipenv/11.9.0_1/libexec/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/Cellar/pipenv/11.9.0_1/libexec/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/usr/local/Cellar/pipenv/11.9.0_1/libexec/lib/python3.6/site-packages/pipenv/cli.py", line 642, in check
three=three, python=python, system=system, unused=unused, args=args
File "/usr/local/Cellar/pipenv/11.9.0_1/libexec/lib/python3.6/site-packages/pipenv/core.py", line 2275, in do_check
results = simplejson.loads(c.out)
File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/__init__.py", line 354, in loads
return _default_decoder.decode(s)
File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/decoder.py", line 357, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
I cannot install anything either:
$ pipenv install pymysql
Installing pymysql…
⠋
Error: An error occurred while installing pymysql!
dyld: Library not loaded: @executable_path/../.Python
Referenced from: /Users/werner/.local/share/virtualenvs/data-analysis-xEhMcwIZ/bin/python3.6
Reason: image not found
Please run $ python -m pipenv.help
, and paste the results here.
/usr/local/opt/python@2/bin/python2.7: No module named pipenv
When I run python3 -m pipenv.help
:
/usr/local/opt/python/bin/python3.6: Error while finding module specification for 'pipenv.help' (ModuleNotFoundError: No module named 'pipenv')
Expected result
I expected to be dropped into the pipenv shell without errors (or warnings, that is).
Actual result
See the errors mentioned above.
Steps to replicate
Provide the steps to replicate (which usually at least includes the commands and the Pipfile):
I installed pipenv via Homebrew, then ran:
pipenv --three
pipenv install matplotlib seaborn pandas scipy numpy SQLAlchemy
pipenv shell
A few days later my Python 3 was updated via Homebrew, if I remember correctly. Not sure if that could cause any problems.
Issue Analytics
- State:
- Created 5 years ago
- Comments:14 (11 by maintainers)
Top Results From Across the Web
The virtual environment found seems to be broken | python ...
Go to your project directory and start Poetry (if you're not already there); get rid of the broken virtual environment,
Read more >Pipenv & Virtual Environments
This tutorial walks you through installing and using Python packages. It will show you how to install and use the necessary tools and...
Read more >Release History — virtualenv 20.17.2.dev2+g6845f6f ...
Fix AttributeError: 'bool' object has no attribute 'error' when creating a Python 2.x virtualenv on macOS - by moreati . (#2269).
Read more >Creating and managing virtual environments - Pydicom |
This means: If you're working on a project and you make a backwards incompatible change, then other projects that depend on it may...
Read more >Installing and using virtualenv with Python 3
Overview Virtualenv is a tool used to create an isolated Python environment. This environment has its own installation directories that...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I did a
pipenv --rm
andpipenv install
, now everything seems to work again.Homebrew is more problematic because this happens for every point release. With python.org installers (and apt, for this matter) this generally happens only every minor release (e.g. 3.5 -> 3.6) because it tries to maintain binary compatibility between point releases, which makes problems happen less frequently and more obvious to debug. Homebrew also does not try to keep multiple versions of a software around (it does not delete it when you upgrade, but will feel free to clean it up when it sees fit), so you need to take extra care to keep (for example) 3.5 environments working after 3.6 is out. With python.org installers (and apt, again) you can easily have 3.5 and 3.6 installations exist side-by-side.
Note: It is possible achieve the same side-by-side installation in Homebrew, but the procedure is much more awkward, and does not transition well from the default Python installation if you don’t start with the correct setup. This is a deficiency in Homebrew’s design, they acknowledge this, but it is really difficult to do (I don’t blame them to leave things as-is).