简体   繁体   English

PyPDF2 不会导入

[英]PyPDF2 won't import

Hi I'm just getting started with python and trying to get some requisite libraries installed.嗨,我刚刚开始使用 python 并尝试安装一些必要的库。 Using Python 3.4.1 on OS X. I have installed PyPDF2 (with supposed success), yet I cannot seem to use the tools:在 OS X 上使用 Python 3.4.1。我已经安装了 PyPDF2(假设成功),但我似乎无法使用这些工具:

    sh-3.2# port select --list python
    Available versions for python:
        none
        python25-apple
        python26
        python26-apple
        python27-apple
        python34 (active)
    sh-3.2# pip install PyPDF2
    Requirement already satisfied (use --upgrade to upgrade): PyPDF2 in /opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages
Cleaning up...
sh-3.2# 

... ...

import PyPDF2
Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    import PyPDF2
ImportError: No module named 'PyPDF2'
>>> 

Am I missing a step?我错过了一步吗? Or is PyPDF2 not supported in py3.4.1?还是 py3.4.1 不支持 PyPDF2?

PyPDF2 is compatible with Python 3.4, so that's not the problem. PyPDF2与 Python 3.4 兼容,所以这不是问题。

In which Python version do you have pip installed?您在哪个 Python 版本中安装了 pip? Even though you're on python34 , if pip is installed to a different version it will download libraries to that version.即使您使用的是python34 ,如果 pip 安装到不同的版本,它也会将库下载到该版本。

In any case, you can always install by downloading from PyPI , then running setup.py install .在任何情况下,您始终可以通过从PyPI下载,然后运行setup.py install来安装。

Still, the only possible explanation I have is that the current Python version you're on does not have PyPDF2 installed.尽管如此,我唯一可能的解释是您当前使用的 Python 版本没有安装 PyPDF2。 See if you can import PyPDF2 from any of the other versions.看看您是否可以从任何其他版本导入 PyPDF2。

您可以使用以下命令安装PyPDF2

pip install PyPDF2

In my case: pip3 install PyPDF2 with python in /usr/local/bin就我而言: pip3 install PyPDF2 with python in /usr/local/bin

[tim@axelrod utils] (hotfix/2.3.2)$ ls -l /usr/local/bin/python*
lrwxr-xr-x  1 root  admin    22 10 May  2017 /usr/local/bin/python -> /usr/local/bin/python3
lrwxr-xr-x  1 tim   admin    35  3 May  2017 /usr/local/bin/python3 -> ../Cellar/python3/3.6.1/bin/python3
lrwxr-xr-x  1 tim   admin    42  3 May  2017 /usr/local/bin/python3-config -> ../Cellar/python3/3.6.1/bin/python3-config
lrwxr-xr-x  1 tim   admin    37  3 May  2017 /usr/local/bin/python3.6 -> ../Cellar/python3/3.6.1/bin/python3.6
lrwxr-xr-x  1 tim   admin    44  3 May  2017 /usr/local/bin/python3.6-config -> ../Cellar/python3/3.6.1/bin/python3.6-config
lrwxr-xr-x  1 tim   admin    38  3 May  2017 /usr/local/bin/python3.6m -> ../Cellar/python3/3.6.1/bin/python3.6m
lrwxr-xr-x  1 tim   admin    45  3 May  2017 /usr/local/bin/python3.6m-config -> ../Cellar/python3/3.6.1/bin/python3.6m-config
-rwxr-xr-x  1 tim   wheel  4119  7 Jan  2012 /usr/local/bin/python_count

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

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