Before asking this question, I have seen the following questions that are somehow similar to my question, but they didn't resolve the existing error:
- ModuleNotFoundError: No module named after pip install
- ImportError: No module… After python setup.py install
I have the following structure:
backbone-project
├── backbone
│ ├── backbone.py
│ ├── cmd_parser.py
│ ├── command_executor.py
│ ├── config_files
│ ├── db_connections
│ ├── extras
│ ├── __init__.py
│ ├── __pycache__
│ ├── query_files
│ ├── templates
│ ├── tests
│ └── utils
├── LICENSE
├── README.md
├── requirements.txt
├── setup.py
and this is my setup.py file:
import setuptools
from backbone.utils.enums import Files, Letters
with open(Files.README.value, Letters.R.value, encoding=Letters.UTF_8.value) as readme_file:
long_description = readme_file.read()
with open(Files.REQUIREMENTS.value, Letters.R.value, encoding=Letters.UTF_8.value) as requirements_file:
requirements = requirements_file.read().splitlines()
setuptools.setup(
name="backbone",
version="1",
entry_points={
"console_scripts": [
'backbone=backbone.backbone:main'
]
},
author="Mostafa Ghadimi",
author_email="my email",
long_description=long_description,
install_requirements=requirements,
# install_requires=requirements,
long_description_content_type="text/markdown",
url="url",
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
package_dir={"": "backbone"},
packages=setuptools.find_packages("backbone"),
python_requires=">=3.6",
license='MIT',
)
backbone/backbone.py
#!/usr/bin/env python
from cmd_parser import parse_args
from utils.logger import Logger
from utils.enums import Messages
def main():
logger = Logger(__name__)
logger.log(Messages.BACKBONE_WELCOME_MSG.value)
parse_args()
if __name__ == '__main__':
main()
The problem is that whenever I want to install the package, it is installed successfully, but as the command is being executed, the error is raised:
requirements.txt
git+https://<username>:<password>@<git_repository_url>.git
and install it using the following command:
pip install -r requirements
(It has been installed without any error.)
As I want to use the package (in bash), I face to following error:
Traceback (most recent call last):
File "/home/user/.local/bin/backbone", line 5, in <module>
from backbone import main
ImportError: cannot import name 'main' from 'backbone' (unknown location)
How can I resolve this error?
P.S. 1 On local after exporting PYTHONPATH
the problem is resolved, but the problem still exists when I want to install the package from git repository!
P.S. 2 I am somehow sure that the problem is with entry_points
. I have also tried backbone:main
but it doesn't work!