Python Forum
Encountering `importlib_metadata.PackageNotFoundError` trying to run console script
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Encountering `importlib_metadata.PackageNotFoundError` trying to run console script
#1
# Background

I have a pipenv workspace which is structured like this:

|- Pipfile
|- Pipfile.lock
|- assetdb-SNAPSHOT/
   |- setup.py
   |- assetdb/
      |- __init__.py
      |- (other modules)
The Pipfile references the assetdb-SNAPSHOT directory by local path:

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

[packages]
assetdb = {editable = true, path = 'assetdb-SNAPSHOT'}

[dev-packages]

[requires]
The assetdb-SNAPSHOT/setup.py file declares assetdb to be a console_scripts entrypoint:

from setuptools import setup, find_packages

setup(
    packages=find_packages(),
    entry_points={'console_scripts': ['assetdb=assetdb.porcelain.cli:main']},
    name='assetdb',
    version='0.0.1-SNAPSHOT',
    install_requires=['pyyaml==5.3.1', 'pytest==6.0.2', 'pytest-rng==1.0.0'],
)
# Problem

However, when I attempt to run pipenv run assetdb, I get this error:


Traceback (most recent call last):
  File "/Users/kahlo/.local/share/virtualenvs/pypackages-988kgfpK/bin/assetdb", line 33, in <module>
    sys.exit(load_entry_point('assetdb', 'console_scripts', 'assetdb')())
  File "/Users/kahlo/.local/share/virtualenvs/pypackages-988kgfpK/bin/assetdb", line 22, in importlib_load_entry_point
    for entry_point in distribution(dist_name).entry_points
  File "/Users/kahlo/.local/share/virtualenvs/pypackages-988kgfpK/lib/python3.7/site-packages/importlib_metadata/__init__.py", line 940, in distribution
    return Distribution.from_name(distribution_name)
  File "/Users/kahlo/.local/share/virtualenvs/pypackages-988kgfpK/lib/python3.7/site-packages/importlib_metadata/__init__.py", line 534, in from_name
    raise PackageNotFoundError(name)
importlib_metadata.PackageNotFoundError: No package metadata was found for assetdb
# Diagnostics

I am able to use pipenv to enter a python shell, import the main function, and run it, and it works:

Phoenixs-MacBook-Pro:pypackages kahlo$ pipenv run python
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 26 2018, 23:26:24) 
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import assetdb.porcelain.cli
>>> assetdb.porcelain.cli.main()
usage:  [-h] [--cwd [CWD]]
        {init,status,upload,add,remove,sync-file-to-hash,sync-hash-to-file,stash,checkout}
        ...
Therefore, the problem lies somewhere in this configuration's ability to locate the entrypoint based on the command.

---

Help much appreciated
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Combine console script + GUI (tkinter) dejot 2 361 Feb-27-2024, 04:38 PM
Last Post: deanhystad
  Make console show after script was built with Pyinstaller --NOCONSOLE? H84Gabor 0 1,189 May-05-2022, 12:32 PM
Last Post: H84Gabor
  IPython console vs Spyder script losc 3 2,673 Apr-30-2020, 04:57 AM
Last Post: deanhystad
  Problem running script within console koepjo 3 9,804 Mar-26-2020, 07:11 AM
Last Post: koepjo
  Spyder : Clear IPython Console whenever I re-run the script smallabc 0 5,214 Mar-04-2018, 08:05 AM
Last Post: smallabc
  Dict KeyError in cgi-bin script, works fine via console dbsoundman 2 3,870 Jul-21-2017, 08:03 PM
Last Post: dbsoundman

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020