python - 我的项目无法检测到在 python 上安装的模块

标签 python linux pyramid

我已经安装了 PyPDF2。

$ sudo pip install PyPDF2

安装成功

Collecting PyPDF2
Installing collected packages: PyPDF2
Successfully installed PyPDF2-1.26.0

但是当我运行我的项目时,它产生了一个错误。

ImportError: No module named 'PyPDF2'
Server with PID 19740 exited with code 1.
Waiting for changes before reloading.

当然,如果我评论这个模块,我的项目就会运行,但我需要它。 对于那些可以提供帮助的人,提前致谢!

只是为了了解更多信息,我使用的是 Ubuntu 16.04.2 LTS 并且我使用 Pyramid 作为我的框架 (Python)。

我尝试使用

pip install PyPDF2

但是

  File "/usr/lib/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/pyPdf'

编辑: 的输出 点卡住

adium-theme-ubuntu==0.3.4
beautifulsoup4==4.4.1
Chameleon==2.24
chardet==2.3.0
cryptography==1.2.3
dnspython==1.12.0
enum34==1.1.2
FormEncode==1.3.0
html5lib==0.999
idna==2.0
ipaddress==1.0.16
lxml==3.5.0
Mako==1.0.3
MarkupSafe==0.23
Paste==1.7.5.1
PasteDeploy==1.5.2
PasteScript==1.7.5
pyasn1==0.1.9
pyinotify==0.9.6
pyOpenSSL==0.15.1
PyPDF2==1.26.0
python-openid==2.2.5
repoze.lru==0.6
scgi==1.13
six==1.10.0
Tempita==0.5.2
translationstring==1.3
unity-lens-photos==1.0
venusian==1.0a8
virtualenv==15.1.0
waitress==0.8.10
WebOb==1.5.1
WebTest==2.0.18
zope.component==4.2.2
zope.deprecation==4.1.2
zope.event==4.2.0
zope.hookable==4.0.4
zope.interface==4.1.3

最佳答案

您必须使用连接到该 virtualenv 的 pip 将 pypdf2 安装到您的 virtualenv 中。

env/bin/pip install pypdf2

任何其他操作都会将包安装到错误的环境中... sudo pip install 会将其放入系统的站点包中,而 pip install 会将其安装到系统的站点包,但会失败,因为您的用户不是根用户(唯一有权更改系统站点包的用户)。

关于python - 我的项目无法检测到在 python 上安装的模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43908294/

相关文章:

python - 在Python中设计类似C的结构的最佳方法

python - Pygame BLEND_RGBA_ADD 与 screen.blit

python 日志记录 - 使用 JSON 日志,我可以向每个日志添加 "extra"值吗?

javascript - Amcharts 图像 "304 Not Modified"错误

python - SQLAlchemy - 获取表列表

python - Sonar 不知道 Pylint 规则

linux - 是否可以在当前 shell 中禁用 sudo 超时?

linux - 从帧缓冲区读取之前是否需要使缓存失效?

python - 如何打开 Pyramid 内的文件进行读取?

python - Pyramid 订户谓词不起作用