I've written a small python code that parses data from a file and then uses Selenium to input the data into a website, and I am trying to bundle it with a script.
I was already able to bundle it into a pip package and upload it, but when trying to run it I get ImportError: No module named '<name>'
for modules on the same directory.
My structure is pretty simply
chessil_tourney_inserter/
setup.py
chessil_tourney_inserter/
__init__.py (empty)
chessil_tourney_inserter.py
swiss98_text_parser.py
command_line.py
And the setup.py is also pretty basic:
from setuptools import setup
setup(name='chessil_tourney_inserter',
.
.
.
packages=['chessil_tourney_inserter'],
zip_safe=False,
install_requires = [
'selenium'
],
entry_points={
'console_scripts': [
'insertchessiltourney = chessil_tourney_inserter.command_line:main']
})
As of right now command_line.main
simply calls chessil_tourney_inserter
:
import chessil_tourney_inserter.chessil_tourney_inserter as cti
import sys
def main():
if len(sys.argv) == 1:
print("Usage: chessil_tourney_inserter.py *tournament name*")
exit()
cti.main();
if __name__ == "__main__":
main()
and chessil_tourney_inserter gives me an import error on:
import swiss98_text_parser
but if I try to run chessil_tourney_inserter.py
directly it works, and if I add the package name to the import it would break chessil_tourney_inserter.py
So how am I supposed to set up the files so that imports will work correctly both when I run the file directly myself, and when I try to import it as a package or run it as a script?