I am packaging my first python project, and I have two files with helper functions, comments.py and score.py stored in the subdirectory.
YT_Sentiments/
└── src/
├── YT_Sentiments/
│ ├── helpers/
│ │ ├── __init__.py
│ │ ├── score.py
│ │ └── comments.py
│ ├── __init__.py
│ └── main.py
├── LICENSE
├── pyproject.toml
├── README.md
└── setup.py
in my main.py I import the two files
from helpers import score.py
from helpers import comments.py
When I build and install it locally, I get the error:
File "C:UsersAppDataLocalProgramsPythonPython311Libsite-packagesYT_Sentimentsmain.py", line
1, in <module>
from helpers import score
ModuleNotFoundError: No module named 'helpers'
I have followed atleast 4 tutorials on packaging and implemented what I thought would solve my problem (setup.py and pyproject.toml)
setup.py
from setuptools import find_packages, setup
with open("README.md") as f:
long_description = f.read()
setup(name = "YT_Sentiments",
version = "0.0.4",
description = "analyze comments from any youtube video!",
package_dir = {"":"YT_Sentiments"},
packages = find_packages(where="YT_Sentiments"),
long_description=long_description,
long_description_content_type="text/markdown",
license = "MIT",
classifiers=[
"Programming Language :: Python",
"Topic :: Software Development :: Libraries :: Python Modules",
"Operating System :: OS Independent",
],
install_requires = ["emoji>=2.12.1",
"google_api_python_client>=2.139.0",
"vaderSentiment>=3.3.2",
"vaderSentiment>=3.3.2",],
python_requires = ">=3.8",
)
pyproject.toml
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
name = "YT_Sentiments"
version = "0.0.4"
description = "A python package that allows you to perform sentiment analysis on Youtube comments"
readme = "README.md"
requires-python = ">=3.8"
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
]
dependencies = [
"emoji>=2.12.1",
"google_api_python_client>=2.139.0",
"vaderSentiment>=3.3.2",
"vaderSentiment>=3.3.2",
]
[project.urls]
Homepage = "https://github.com/pypa/sampleproject"
Issues = "https://github.com/pypa/sampleproject/issues"`
New contributor
ZHENG JIAWEN is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.