I want to create a python application called knife that can be executed from the CLI, the problem is that it cannot import modules. I followed the same folder structure as the Django project for reference.
My directory structure is this:
knife/ knife/ bin/ knife-cli.py core/ main/ __init__.py __init__.py __init__.py setup.py
My setup.py looks like this:
#!/usr/bin/env python from setuptools import setup, find_packages exclude = ['knife.bin'] setup(name='Knife', version='0.3', description='Very cool project', author='John Doe', author_email=' author@email.com ', packages=find_packages(exclude=exclude), include_package_data=True, scripts=['knife/bin/knife-cli.py'], entry_points={ 'console_scripts': [ 'knife-cli = knife.core.main:main' ] }, zip_safe=False, )
My knife/core/main/__init__.py contains the main() function, and my knife/bin/knife-cli.py looks like this:
#!/usr/bin/env python from knife.core import main if __name__ == "__main__": main.main()
So, after installing the module with installing setup.py, I try to start knife-cli, but continue to throw this error:
$ knife-cli Traceback (most recent call last): File "/usr/bin/knife-cli", line 9, in <module> load_entry_point('Knife==0.3', 'console_scripts', 'knife-cli')() File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 468, in load_entry_point return get_distribution(dist).load_entry_point(group, name) File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2563, in load_entry_point return ep.load() File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2254, in load ['__name__']) File "/usr/bin/knife.py", line 4, in <module> File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 646, in run_script self.require(requires)[0].run_script(script_name, ns) File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 1559, in run_script raise ResolutionError("No script named %r" % script_name) pkg_resources.ResolutionError: No script named 'knife.py'
What is really going on? and how can i solve it?