pipenv: ModuleNotFoundError when running installed packages

I am seeing this issue with lots of packages that have a command-line entry point (at least pytest and honcho):

$ pipenv --version
pipenv, version 3.2.0

$ pipenv install honcho
Installing honcho...
Collecting honcho
  Using cached honcho-0.7.1-py2.py3-none-any.whl
Installing collected packages: honcho
Successfully installed honcho-0.7.1

Adding honcho to Pipfile's [packages]...

$ pipenv run honcho
Traceback (most recent call last):
  File "<root>/.venv/bin/honcho", line 7, in <module>
    from honcho.command import main
ModuleNotFoundError: No module named 'honcho'

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 19 (15 by maintainers)

Commits related to this issue

Most upvoted comments

Weirdly, $ pipenv run python -m pytest does work.

I’m having this exact same issue with a new package I’m working on… https://github.com/fny/thecurator/tree/pipenv-failure

The jsonschema package can’t be found in the tests even though it’s clearly installed in the virtualenv.

(thecurator-9LuGzVpd) bash-4.4 $ pipenv run pip list
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
jsonschema (2.6.0)
pip (9.0.3)
pyaml (17.12.1)
PyYAML (3.12)
setuptools (39.0.1)
SQLAlchemy (1.2.5)
wheel (0.30.0)

(thecurator-9LuGzVpd) bash-4.4$ pipenv run pytest tests
================================================================================ test session starts ================================================================================
platform darwin -- Python 3.6.4, pytest-3.1.3, py-1.4.34, pluggy-0.4.0
rootdir: /Users/faraz/Workspace/thecurator, inifile:
collected 5 items / 1 errors

====================================================================================== ERRORS =======================================================================================
______________________________________________________________________ ERROR collecting tests/test_curation.py ______________________________________________________________________
ImportError while importing test module '/Users/faraz/Workspace/thecurator/tests/test_curation.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
tests/test_curation.py:2: in <module>
    from thecurator.private import IS_PYPY, pypy_incompatible
thecurator/__init__.py:4: in <module>
    from .private.table_description import Registry
thecurator/private/table_description.py:6: in <module>
    import jsonschema
E   ModuleNotFoundError: No module named 'jsonschema'

I figured out that I was not installing the packages in dev-packages block. Using pipenv install -d solved the problem.