Reputation: 1839
I have a package with the following directory structure:
mypackage
mypackage
__init.py__
users.py
bin
mypackage.py
setup.py
My setup.py looks like this:
from setuptools import setup, find_packages
setup(
name='mypackage.py',
version='0.9',
packages=find_packages(),
scripts=['bin/mypackage.py'],
install_requires=['np', 'filelock', 'python-dateutil', 'requests', 'numpy'])
The __init__.py contains:
import mypackage.users
My bin/mypackage.py includes among other things:
from mypackage.users import *
I am running
python3 setup.py install
Everything works great and then on the terminal I type:
mypackage.py
and I am greeted with the following error:
from mypackage.users import *
ImportError: No module named 'mypackage.users'; 'mypackage' is not a package
If I attempt:
python3
import mypackage
I get no errors. I also use virtualenv (not shown here) but I am sure there are no other conflicts.
Upvotes: 0
Views: 592
Reputation: 1839
Long story short, executable script cannot have the same name like the package. Lost 3 hours of my life.
Upvotes: 7