Reputation: 14033
I would like to install a script with setuptools and have the following setup:
In my development directory there are the files
The z_script.py
file looks like this:
def main():
print "Running..."
while my setup.py
looks like this:
from setuptools import setup
setup(
name = 'z_script', version = '0.2',
entry_points = {"console_scripts": ["z_script = z_script:main"]},
)
When I run python setup.py install
the script successfully gets installed into the correct bin
directory.
However, when I run the script with z_script
an error occurs:
Traceback (most recent call last):
File "./z_script", line 8, in <module>
load_entry_point('z-script==0.2', 'console_scripts', 'z_script')()
File "/home/woltan/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 318, in load_entry_point
File "/home/woltan/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 2221, in load_entry_point
File "/home/woltan/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 1954, in load
ImportError: No module named z_script
The bin
directory is accessible through the PATH
environment variable from thought the system and no PYTHONPATH
environment variable is set when I issue the z_scirpt
.
And now to my question:
What is wrong in my setup? Why isn't the script finding the correct module?
Upvotes: 4
Views: 3431
Reputation: 8012
You don't instruct setuptools to install the z_script
. Use find_packages
or list z_script
in the py_modules
keyword.
...
packages = find_packages(),
...
or
...
py_modules = ['z_script'],
...
Upvotes: 5