So I'm trying to add a new script I wrote, fakesky
, to PyPi as a module. I uploaded it to PyPi, and pip will let me install it successfully, but every time I try to import it, I get the following error:
ModuleNotFoundError: No module named 'fakesky'
The structure of the upload is as follows:
fakesky ->
setup.py
setup.cfg
README.txt
LICENSE
src ->
__init__.py (empty file)
fakesky.py
results_BB.txt (necessary file that fakesky.py reads)
And the relevant files are as follows:
setup.py:
from setuptools import setup, find_packages
setup(
name='fakesky',
version='1.0.2',
license='CC0 1.0',
author="Drew Weisserman",
author_email='[email protected]',
packages=find_packages('src'),
package_dir={'': 'src'},
url='https://github.com/drewweis/fakesky',
keywords='sky image',
install_requires=[
'matplotlib',
'numpy',
'pandas',
'scipy',
'astropy'
],
)
setup.cfg:
[metadata]
description-file=README.md
license_files=LICENSE.rst
I performed the following commends to upload it:
[cd to inside fakesky folder]
python3 setup.py sdist
twine upload dist/*
Can anyone tell me what I'm doing wrong?
The directory structure is wrong. Recreate like this:
fakesky ->
setup.py
setup.cfg
README.txt
LICENSE
src ->
fakesky ->
__init__.py (empty file)
fakesky.py
results_BB.txt (necessary file that fakesky.py reads)
By the way, I recommend to name the module differently than the top-level package name, to avoid confusing imports like from fakesky import fakesky
.