简体   繁体   English

无法导入pypi模块

[英]Unable to import pypi module

I am unable to import the pypi module ( https://pypi.org/project/pypi/ ) into one of my python scripts. 我无法将pypi模块( https://pypi.org/project/pypi/ )导入到我的python脚本之一中。

I added the below line to my script to see which paths it's trying to get modules from: 我将以下行添加到脚本中,以查看其试图从中获取模块的路径:

print(sys.path)

Which shows the following: 显示以下内容:

`'/usr/local/lib/python3.5/dist-packages/', '/usr/lib/python3.5/dist-packages']

I have used pip to force the installation into those specific folders: 我已经使用pip强制将安装安装到这些特定的文件夹中:

sudo pip3 install --upgrade --target=/usr/local/lib/python3.5/dist-packages/ pypi
sudo pip3 install --upgrade --target=/usr/lib/python3.5/dist-packages pypi

In both cases the installation is successful: 在两种情况下,安装均成功:

Collecting pypi
Installing collected packages: pypi
Successfully installed pypi-2.1

If I go check those folders, the package is there: 如果我去检查那些文件夹,则包在那里:

ls -lh /usr/lib/python3.5/dist-packages | grep pypi
drwxr-xr-x 2 root root 4.0K Apr 25 11:03 pypi-2.1.dist-info
drwxr-xr-x 2 root root 4.0K Apr 25 10:49 pypi-2.1-py3.5.egg-info

If I manually install the package I get something similar: 如果手动安装该软件包,则会得到类似的结果:

python3.5 ./setup.py install
running install
running build
running install_egg_info
Writing /usr/local/lib/python3.5/dist-packages/pypi-2.1.egg-info

Here is my script : 这是我的脚本

import sys
print(sys.path)
import pypi

And the error I get: 我得到的错误是:

$ python3.5 myscrypt.py
[..., '/usr/local/lib/python3.5/dist-packages','/usr/lib/python3.5/dist-packages']
import pypi
ImportError: No module named 'pypi'

What am I missing to import pypi ? 我要导入pypi我缺少什么?

There are no importable modules or packages in the pypi package. pypi软件包中没有可导入的模块或软件包。 The package was created to reserve the name so that evil hackers don't publish packages with this name. 创建该软件包是为了保留该名称,以便邪恶的黑客不会发布使用该名称的软件包。

What are really trying to install? 真正要安装的是什么?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM