[英]ModuleNotFoundError when running python script installed via deb created using stdeb
I've build a really simple Python project I'm packaging into a.deb file for installation.我已经构建了一个非常简单的 Python 项目,我正在打包到一个 .deb 文件中进行安装。 I've got the building of.deb working, but when I run my script via it's command, I get a ModuleNotFoundError.我已经构建了.deb,但是当我通过它的命令运行我的脚本时,我得到了一个 ModuleNotFoundError。
My project structure is as follows:我的项目结构如下:
setup.py
hello
|
| - __init.py__
| - hello.py
| - world.py
setup.py安装程序.py
import os
from setuptools import setup, find_packages
setup(
name = "hello_py",
version = "1.3",
author = "Sion Hughes",
author_email = "",
description = "It's a simple hello world, but this time with 2 python file",
license = "",
url = " ",
packages=find_packages(),
entry_points = {
'console_scripts' : ['hello = hello.hello:main',
'command-name = hello.hello:main']
},
classifiers=[
"License :: OSI Approved :: BSD License",
],
)
hello.py你好.py
#!/usr/bin/env python3
import world
def main():
print("Hello, this is Siôn's python script")
world.hello()
if __name__ == "__main__":
main()
world.py世界.py
#!/usr/bin/env python3
def hello():
print("Hello from another Python file")
All runs fine locally, but when I run using hello
command, I get the following error:一切在本地运行良好,但是当我使用hello
命令运行时,出现以下错误:
# hello
Traceback (most recent call last):
File "/usr/bin/hello", line 11, in <module>
load_entry_point('hello-py==1.3', 'console_scripts', 'hello')()
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 490, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2854, in load_entry_point
return ep.load()
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2445, in load
return self.resolve()
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2451, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/usr/lib/python3/dist-packages/hello/hello.py", line 5, in <module>
import world
ModuleNotFoundError: No module named 'world'
Where am I going wrong to get this working?我在哪里错了让这个工作? Thanks in advance.提前致谢。
Update: Forgot to say in the initial post, I want to be able to run the scripts in their local directory for development purposes too, not just always run via installed.deb更新:忘了在最初的帖子中说,我也希望能够在其本地目录中运行脚本以用于开发目的,而不仅仅是通过 installed.deb 运行
Instead of import world
in hello.py, try using import.world
.不要在 hello.py 中import world
,而是尝试使用import.world
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.