question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

setuptools integration using "Scripts in Packages" example - not working

See original GitHub issue

I am following the setuptools example using a python3.7.1 conda virtual env from the documentation here and continue to receive an error:

ModuleNotFoundError: No module named 'yourpackage.scripts'

yourpackage/
├── __init__.py
├── main.py
├── scripts
│   ├── __init__.py
│   └── yourscript.py
├── setup.py
└── utils.py
#scripts/yourscript.py

import click

@click.command()
def cli():
    """Example script."""
    click.echo('Hello World!')
# setup.py

from setuptools import setup, find_packages
setup(
    name='yourpackage',
    version='0.1',
    packages=find_packages(),
    include_package_data=True,
    install_requires=[
        'Click',
    ],
    entry_points='''
        [console_scripts]
        yourscript=yourpackage.scripts.yourscript:cli
    ''',
)
$ pip install -e .
Looking in indexes: https://InternalArtifactoryUrl
Obtaining file:///private/tmp/yourpackage
Requirement already satisfied: Click in /Users/myusername/miniconda3/envs/test_20190220/lib/python3.7/site-packages (from yourpackage==0.1) (7.0)
Installing collected packages: yourpackage
  Found existing installation: yourpackage 0.1
    Uninstalling yourpackage-0.1:
      Successfully uninstalled yourpackage-0.1
  Running setup.py develop for yourpackage
Successfully installed yourpackage

$ which yourscript
/Users/myusername/miniconda3/envs/test_20190220/bin/yourscript

$ yourscript
Traceback (most recent call last):
  File "/Users/myusername/miniconda3/envs/test_20190220/bin/yourscript", line 11, in <module>
    load_entry_point('yourpackage', 'console_scripts', 'yourscript')()
  File "/Users/myusername/miniconda3/envs/test_20190220/lib/python3.7/site-packages/pkg_resources/__init__.py", line 489, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/Users/myusername/miniconda3/envs/test_20190220/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2793, in load_entry_point
    return ep.load()
  File "/Users/myusername/miniconda3/envs/test_20190220/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2411, in load
    return self.resolve()
  File "/Users/myusername/miniconda3/envs/test_20190220/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2417, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
ModuleNotFoundError: No module named 'yourpackage.scripts'

I also tried: export PYTHONPATH=/tmp/yourpackage/ and continue to receive the error when running yourscript

UPDATE The workaround was simply: export PYTHONPATH=/tmp/yourpackage/

Is it possible to update the documentation to make it clearer to newcomers such as myself?

Thanks!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
bittnercommented, Feb 25, 2019

Thanks, @be-rock, for reporting the issue! Do the docs make things clearer for you now?

0reactions
be-rockcommented, Feb 28, 2019

Yes, very much so @bittner. Thanks! And yes I am new to setuptools so appreciate the extra bit of clarification.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Setuptools Integration — Click Documentation (8.1.x)
The main trick only works if the script is a Python module. If your application grows too large and you want to start...
Read more >
python click setuptools integration issue - Stack Overflow
#scripts/yourscript.py import click @click.command() def cli(): """Example script.""" click.echo('Hello World!')
Read more >
How to Package Python dependencies with PIP setuptools
Simply put, setup.py is a build script template distributed with Python's setuptools package. Setuptools is the Python Packaging Authority (PyPA) ...
Read more >
Configuring setuptools using setup.cfg files
Setuptools allows using configuration files (usually setup.cfg ) to define a package's metadata and other options that are normally supplied to the setup() ......
Read more >
2. Writing the Setup Script — Python 3.11.1 documentation
If you, for example, use standard Python functions such as glob.glob() or ... the Distutils will issue a warning but still process the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found