I've been building a simple CLI.
My main.py
looks like this:
import prompt <- This is my file
import utils <- This too.
# blah blah blah
When I just ran python3 main.py
, it works just fine. But after running python3 setup.py install
and running myCLI somecommand
on my terminal, I got this:
0.0.1-py3.9.egg/testCVRCLI/main.py", line 1, in <module>
ModuleNotFoundError: No module named 'prompt'
I checked whether it works by running python3 main.py
, and it worked fine.
EDIT
# main.py
import prompt
import utils
import click
@click.group()
def main():
pass
@main.command()
def setupdb():
# some code
@main.command()
def create_data():
# some code
if __name__ == "__main__":
if platform.system() != "Darwin":
utils.print("This is currently only for Mac users.")
else :
main()
My directory structure looks like this:
testCVRCLI
|- setup.py
|- CVRCLI_folder
|- __init__.py
|- main.py
|- prompt.py
|- utils.py
My setup.py
from setuptools import setup, find_packages
# Setting up
setup(
name="myCLI",
version=VERSION,
author="My Name",
author_email="My Email",
description=DESCRIPTION,
long_description=LONG_DESCRIPTION,
long_description_content_type="text/markdown",
packages=find_packages(),
install_requires=[
"click",
"mysql-connector-python",
"protobuf",
"six",
],
license="MIT",
classifiers= [
"Environment :: Console",
"Development Status :: 2 - Pre-Alpha",
],
entry_points = """
[console_scripts]
myCLI=CVRCLI_folder.main:main
"""
)