I'm having trouble installing one of my python scripts. It has the following structure:
myproject
setup.py
src
myproject
otherfolders
main.py
__init__.py
And my setup.py
creates an entry point like this:
from setuptools import setup, find_packages
setup(name='mypackage',
version='2.4.0',
author='me',
author_email='...',
package_dir={'':'src'},
packages=find_packages('myproject'),
install_requires=[
"networkx",
"geopy",
"pyyaml"
],
zip_safe=False,
entry_points={
'console_scripts': [
'myproject=myproject.main:main',
],
},
)
Now, after installing this successfully with sudo python setup.py install
, I run mypackage
and get an import error: No module named mypackage.main
.
I am aware that there are lots of similar questions and I tried most/all solutions suggested here, e.g., checking the __init__.py
and setting PYTHONPATH
, but the problem still exists.
I'm running this on two different Ubuntu 16.04 machines.
I'm pretty sure this worked before, but even when I go back to an earlier commit it doesn't work now.
I noticed the installation works with develop
but still fails with install
. Does that make sense to anyone?
The problem was in find_packages()
:
Some projects use a src or lib directory as the root of their source tree, and those projects would of course use "src" or "lib" as the first argument to
find_packages()
.
Hence, I had to change find_packages('myproject')
to find_packages('src')
.