PyPDF2不会导入

时间:2014-08-10 00:02:44

标签: python import install pypdf

您好我刚刚开始使用python并尝试安装一些必需的库。在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'
>>> 

我错过了一步吗?或py3.4.1中不支持PyPDF2?

3 个答案:

答案 0 :(得分:2)

您可以使用以下命令

安装 PyPDF2
pip install PyPDF2

答案 1 :(得分:1)

PyPDF2 与Python 3.4兼容,所以这不是问题。

你在哪个Python版本中安装了pip?即使你在python34,如果将pip安装到另一个版本,它也会将库下载到该版本。

在任何情况下,您都可以通过从PyPI下载,然后运行setup.py install来安装。

尽管如此,我唯一可能的解释是,你所使用的当前Python版本安装了PyPDF2。看看你是否可以从任何其他版本导入PyPDF2。

答案 2 :(得分:0)

在我的情况下:pip3在/ usr / local / bin中使用python安装PyPDF2

[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