Skip to content

Provide better error message if the project’s virtual environment is broken #1918

@slhck

Description

@slhck

Was: "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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: Enhancement 💡This is a feature or enhancement request.good first issueIssues suitable as a newcomer to get familiar with Pipenv!

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions