Python 如何使用 Windows 安装 pyPDF2 模块?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22106380/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I install pyPDF2 module using windows?
提问by Noah Huntington
As a newbie... I am having difficulties installing pyPDF2 module. I have downloaded. Where and how do I install (setup.py) so I can use module in python interpreter?
作为新手......我在安装 pyPDF2 模块时遇到了困难。我已经下载了。我在哪里以及如何安装 (setup.py) 以便我可以在 python 解释器中使用模块?
采纳答案by User
To install setup.py files under Windows you can choose this way with the command line:
要在 Windows 下安装 setup.py 文件,您可以使用命令行选择这种方式:
- hit windows key
- type cmd
- excute the command line (black window)
- type
cd C:\Users\User\Downloads\pyPDF2to go into the directory where thesetup.pyis (this is mine if I downloaded it) The path can be copied from the explorer window. - type
dirnow you should see the name setup.py in the listing of all contents - type
C:\python27\python.exe setup.py installI use Python2.7 here. UseC:\python33\python.exe setup.py installfor python 3.3 and so on. You can follow these instructions now if you wish: http://docs.python.org/2/install/index.html
- 按 Windows 键
- 输入cmd
- 执行命令行(黑窗)
- 键入
cd C:\Users\User\Downloads\pyPDF2进入所在目录setup.py(如果我下载了它,这是我的)路径可以从资源管理器窗口复制。 - 键入
dir现在你应该看到名称setup.py中的所有内容列表 - type
C:\python27\python.exe setup.py install我在这里使用 Python2.7。使用C:\python33\python.exe setup.py installPython的3.3等。如果您愿意,现在可以按照以下说明进行操作:http: //docs.python.org/2/install/index.html
Another way, that does not show when there are problems, is:
另一种在出现问题时不显示的方法是:
- create a shortcut to
setup.py - open the properties of the shortcut. There should be a path like this:
C:\Users\User\Downloads\pyPDF2\setup.py(this is where my setup.py is) you modify that path in the following way:
"C:\Users\User\Downloads\pyPDF2\setup.py" installThe
"are important if you have white spaces in the path name- click OK to save the modifications to the setup.py - shortcut
- double-click the setup.py - shortcut.
- 创建快捷方式
setup.py - 打开快捷方式的属性。应该有这样的路径:(
C:\Users\User\Downloads\pyPDF2\setup.py这是我的 setup.py 所在的位置) 您可以通过以下方式修改该路径:
"C:\Users\User\Downloads\pyPDF2\setup.py" install"如果路径名中有空格,这很重要- 单击确定将修改保存到 setup.py - 快捷方式
- 双击 setup.py - 快捷方式。
In all cases you may need to restart your python to be able to import the module.
在所有情况下,您可能需要重新启动 python 才能导入模块。
When you do this feel free to post your solution also with pictures for other newbies looking for it.
当您这样做时,请随意发布您的解决方案,并附上图片供其他新手寻找。
回答by Madyo
Here's how I did it: After you have downloaded and installed Python (it usually installs under C:\Python** (** being python version - usually 27)), copy the extracted PyPDF2 contents to C:\Python** folder, after that enter in command prompt/terminal "cd C:\Python27\python.exe setup.py install". If you did everything right it should start installing PyPDF2.
我是这样做的:下载并安装 Python(它通常安装在 C:\Python** 下(** 是 python 版本 - 通常为 27))后,将提取的 PyPDF2 内容复制到 C:\Python** 文件夹,之后在命令提示符/终端中输入“cd C:\Python27\python.exe setup.py install”。如果你做的一切都正确,它应该开始安装 PyPDF2。
回答by David Metcalfe
If you have pip, PyPDF2 is on the Python Package Index, so you can install it with the following in your terminal/command prompt:
如果您有 pip,则 PyPDF2 位于 Python 包索引中,因此您可以在终端/命令提示符中使用以下命令安装它:
pip install PyPDF2
pip install PyPDF2
回答by Gabriel Staples
If you have pip, use it to install PyPDF2 from the command line:
如果有pip,请使用它从命令行安装 PyPDF2:
For python2:
对于python2:
pip install PyPDF2
For python3:
对于python3:
pip3 install PyPDF2
Note that if you have multiple versions of python3 installed, you will need to be very explicit. Ex, for Python 3.7:
请注意,如果您安装了多个版本的 python3,则需要非常明确。例如,对于 Python 3.7:
py -3.7 -m pip install PyPDF2
In case you need to upgrade your pipinstaller:
如果您需要升级pip安装程序:
To upgrade pip (for Python 2) in Windows (or Linux, I think):
要在 Windows(或 Linux,我认为)中升级 pip(对于 Python 2):
python -m pip install --upgrade pip
To upgrade pip3 (for Python 3):
升级 pip3(适用于 Python 3):
1) in Windows:
1) 在 Windows 中:
py -3 -m pip install --upgrade pip
OR if you need to be explicit since you have multiple 3.x versions installed:
或者,如果您需要明确表示,因为您安装了多个 3.x 版本:
py -3.7 -m pip install --upgrade pip
2) In Linux I think it is:
2)在Linux中我认为是:
python3 -m pip install --upgrade pip

