I want to make my python app distributable but when I run it from command line from project folder all works well. After the packaging, there is a problem with module import.
All modules exists in package tlen
. In my app I use eg. from Sender import Sender
where Sender is tlen/Sender.py
module.
All works well when I running tlen/main.py
.
Problem exists when I try do package by sudo python setup.py install
and run command tlen
. Then I receive:
File "/usr/lib/python3.7/site-packages/tlen-1.0-py3.7.egg/tlen/main.py", line 3, in <module>ModuleNotFoundError: Nomodule named 'Sender'
Whole project: https://github.com/tloszabno/tl_en
My setup.py file:
setuptools.setup(
name='tlen',
version='1.0',
author='Tomasz Łoś',
author_email='tloszabno@gmail.com',
description='A tool to learn foreign language',
packages=["tlen"],
entry_points={
'console_scripts': [
'tlen = tlen.main:main'
]
},
classifiers=[
'Programming Language :: Python :: 3',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
],
)
What I doing wrong with import
s?
Hah I've solved it!
Just added app.py file to main dir (.. of tlen) with content:
#!/usr/bin/env python
from tlen import main as app
def main():
app.main()
if __name__ == '__main__':
main()
then setup.py:
import setuptools
setuptools.setup(
name='tlen',
version='1.0',
author='Tomasz Łoś',
author_email='tloszabno@gmail.com',
description='A tool to learn foreign language',
packages=["tlen"],
entry_points={
'console_scripts': [
'tlen = app:main'
]
},
classifiers=[
'Programming Language :: Python :: 3',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
],
scripts=[
'app.py',
]
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.