导入错误,而使用PIP安装
程序成功安装使用PIP导入错误,而使用PIP安装
sudo pip install -U rtfd-cli
但显示错误,而使用它:
from helpers import formatstr'
'ImportError: No module named 'helpers'
它工作正常使用
sudo python install setup.py
的实际进口将是这样的:
from rtfd import helpers
#helpers.formatstr is the function you're looking for
您安装RTFD而不是助手。所以Python相应地响应,没有名为helpers的模块。
回答你的问题是:
>>> from rtfd.helpers import formatstr
没用过RTFD,所以我怎么算出这个?
>>> import rtfd
使用Python内置help功能
>>> help(rtfd) # now you see that helpers is an attribute
现在做rtfd.helpers
>>> help(rtfd.helpers) # now you see formatstr function
当我尝试“python3 rtfd.py”时,它显示错误“ImportError:没有名为'rtfd.helpers'的模块;'rtfd'不是一个包” – Nitanshu
从traceback,我相信*助手*导入* rtfd.py * 是不正确的。在* \ Lib \ site-packages \ rtfd *目录中找到* rtfd.py *。打开它并将'helper import formatstr'从'.helpers import formatstr'改为'(这是从相对路径导入的)。保存该文件并重试。 – ScriptCode
SystemError:父模块''未加载,无法执行相对导入 – Nitanshu
你使用任何虚拟ENV一样吗?由于无法运行此命令 - python在不使用任何python虚拟环境时安装不带'sudo'的setup.py 。 –
感谢您指出。用sudo更新了命令。我没有使用任何环境env。 – Nitanshu