[英]import working locally but not after install usinging pip
I was trying to publish a package then install using pip3
and I got this error about importing a module:我试图发布一个包,然后使用
pip3
进行安装,但出现了有关导入模块的错误:
File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/luanrv/codes/tmp/poc-pypkg/poc_pypkg/__main__.py", line 1, in <module>
import utils
ModuleNotFoundError: No module named 'utils'
__main__
file: __main__
文件:
import utils
if __name__ == '__main__':
print('print from __main__')
utils.display_msg()
the same happens for from utils ...
and from .utils ...
.对于
from utils ...
和from .utils ...
。
I don't get much time to understand python's packaging already.我已经没有太多时间去了解 python 的包装了。 Would anyone aux me to solve this?
有人帮我解决这个问题吗?
from poc_pypkg import utils
worked as expected, locally and after publishing/installing using pip. from poc_pypkg import utils
在本地和使用 pip 发布/安装后按预期工作。 I missed up and tried to run using python
instead of python3
, what ran python2 causing the error on importing.我错过了并尝试使用
python
而不是python3
运行,运行 python2 导致导入错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.