Reputation: 610
I'm trying to package an app I've written in Python, and am using setuptools with find_packages to do so. If I run python setup.py develop
(or install
) I get an ImportError:
Traceback (most recent call last):
File "c:\Python34\Scripts\jiragen-script.py", line 9, in <module>
load_entry_point('jiragen==1.0', 'console_scripts', 'jiragen')()
File "x:\jira\jiragen\jiragen\main.py", line 8, in main
import jira_parser, worklogs, exporter
ImportError: No module named 'jira_parser'
jira_parser.py, worklogs.py and exporter.py all exist in the same directory as main.py. Here's my setup.py:
from setuptools import setup, find_packages
setup(
name='jiragen',
version='1.0',
packages = find_packages(),
py_modules = [
'jiragen.main',
'jiragen.jira_parser'
],
install_requires=[
'PyYAML',
'XlsxWriter',
'jsonpickle',
'requests'
],
entry_points={
'console_scripts': [
'jiragen = jiragen.main:main'
]
}
)
Note that I explicity added items to py_modules to see if that would make any difference - but python still complains it can't find jira_parser. Exactly the same error with just find_packages
and no py_modules
. I've tried adding the packages in explicitly too.
My directory structure looks like:
jiragen
|--setup.py
|--jiragen/
|--|--__init__.py
|--|--__main__.py
|--|--main.py
|--|--jira_parser.py
|--|--worklogs.py
|--|--exporter.py
|--|--excel/
|--|--|--__init__.py
|--|--|--(other .py files..)
What am I missing here?
EDIT
Solved - Needed to change the target in 'console_scripts'
from jiragen.main:main
to just jiragen:main
, and add the line package_dir = {'': 'jiragen'}
Upvotes: 4
Views: 2963
Reputation: 1623
You have module jiragen.py
named as parent package. This can be an issue if you use absolute imports.
Upvotes: 3