【发布时间】:2019-05-08 11:02:24
【问题描述】:
我在 pypi 站点“sndboxapi”上创建了一个新的 pip 包,我可以执行 pip install sndboxapi 但我无法在代码中导入它。
我创建了一系列环境,但它们都安装正常,但不仅不允许我使用该模块。
robot@Robot:~/Documents$ python3 -m venv test
robot@Robot:~/Documents$ source test/bin/activate
(test) robot@Robot:~/Documents$ which python
/home/robot/Documents/test/bin/python
(test) robot@Robot:~/Documents$ python
Python 3.6.7(默认,2018 年 10 月 22 日,11:32:17)
(test) robot@Robot:~/Documents$ pip --version
来自 /home/robot/Documents/test/lib/python3.6/site-packages 的 pip 9.0.1 (python 3.6)
(test) robot@Robot:~/Documents$ pip install sndboxapi
收集 sndboxapi
安装收集的包:sndboxapi
成功安装sndboxapi-1.3
(test) robot@Robot:~/Documents$ pip list
弃用:默认格式将来会切换到列。 您可以使用 --format=(legacy|columns) (或定义一个 format=(legacy|columns) 在 [list] 部分下的 pip.conf 中) 禁用此警告。点子(9.0.1)
pkg 资源 (0.0.0)
设置工具 (39.0.1)
sndboxapi (1.3)
(test) robot@Robot:~/Documents$ python
Python 3.6.7(默认,2018 年 10 月 22 日,11:32:17)
>>> import sndboxapi
Traceback(最近一次调用最后一次):
文件“”,第 1 行,在
ModuleNotFoundError: 没有名为“sndboxapi”的模块
我希望输出允许我导入模块,然后允许我调用函数。
【问题讨论】:
-
你试过用
pip3 install sndboxapi安装吗? -
pip3版本与env中的pip命令相同:pip3 install sndboxapi 要求已经满足:sndboxapi in ./test/lib/python3.6/site-packages
-
您能否检查
sndboxapi的文件是否存在于/home/robot/Documents/test/lib/python<your_python_version>/site-packages/中? -
直到我的代码中包含代码的文件夹“脚本”是我在代码中导入时必须引用的名称 感谢您的帮助。我会更新这个。
-
您没有正确导入模块。
from sndbox import sndboxapi。安装看起来不错。
标签: python-3.x pip