[英]How to install a module for python 2.6 on CentOS?
After I install python 2.6 on CentOS by: 我在CentOS上安装python 2.6之后:
wget http://download.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
sudo rpm -ivh epel-release-5-4.noarch.rpm
yum install python26
Then I install pyPdf
by: 然后我通过以下方式安装pyPdf
:
yum install pyPdf
However, the pyPdf
is only available to the old python 2.4: 但是, pyPdf
只适用于旧的python 2.4:
# python
Python 2.4.3 (#1, Jan 9 2013, 06:49:54)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-54)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyPdf
>>> import sys
>>> print sys.path
['', '/usr/lib/python24.zip', '/usr/lib/python2.4', '/usr/lib/python2.4/plat-linux2', '/usr/lib/python2.4/lib-tk', '/usr/lib/python2.4/lib-dynload', '/usr/lib/python2.4/site-packages', '/usr/lib/python2.4/site-packages/Numeric', '/usr/lib/python2.4/site-packages/gtk-2.0']
it's not available to the newly install python 2.6: 它不适用于新安装的python 2.6:
# python26
Python 2.6.8 (unknown, Nov 7 2012, 14:47:34)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-52)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print sys.path
['', '/usr/lib/python26.zip', '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk', '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload', '/usr/lib/python2.6/site-packages']
>>> import pyPdf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named pyPdf
How can I install pyPdf
for python 2.6? 如何为python 2.6安装pyPdf
?
How about creating a virtualenv
and install pyPdf
with pip
如何创建virtualenv
并使用pip
安装pyPdf
$ curl -O https://pypi.python.org/packages/source/v/virtualenv/virtualenv-X.X.tar.gz
$ tar xvfz virtualenv-X.X.tar.gz
$ cd virtualenv-X.X
$ python26 virtualenv.py myVirtualenv
$ source myVirtualenv/bin/activate
$ pip install pyPdf
Not sure how you're doing it. 不确定你是怎么做的。 I have recently installed pyPdf on CentOS for Python 2.7. 我最近在CentOS for Python 2.7上安装了pyPdf。 A simple yum worked for me. 一个简单的yum为我工作。
yum install pyPdf yum安装pyPdf
pyPdf is also available for newer versions. pyPdf也适用于较新版本。 Check here 点击这里
May be having two different versions of Python is causing this issue for you. 可能有两个不同版本的Python导致此问题。 CentOS comes with default installation of v2.4. CentOS附带v2.4的默认安装。 Remove all the previous versions and install again. 删除所有以前的版本并重新安装。
For CentOS version lower than 6, python 2.4 comes by default. 对于低于6的CentOS版本,默认情况下是python 2.4。 For version 6 and above its python2.6 . 对于版本6及更高版本的python2.6。
Now I would strictly advise not to upgrade the base Python installation ie python2.4 in the earlier versions, as that would break lot of system level funcationalities that expect default python to be 2.4. 现在我严格建议不要在早期版本中升级基础Python安装,即python2.4,因为这会破坏许多系统级功能,这些功能期望默认python为2.4。
Your question can be solved in multiple ways : 您的问题可以通过多种方式解决:
Quick installation of Python !!! 快速安装Python !!!
Get the latest verion of Python 2.6.9 获取Python 2.6.9的最新版本
wget https://www.python.org/ftp/python/2.6.9/Python-2.6.9.tar.xz
Extract thae package 提取包装
tar xf Python-2.6.9.tar.xz
Configure them 配置它们
cd Python-2.6.9
./configure --prefix=/usr/local --enable-unicode=ucs4 --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib"
Install them 安装它们
make && make altinstall
Check Version: 检查版本:
python --version
Python 2.6.9
Credits : https://danieleriksson.net 致谢 : https : //danieleriksson.net
Hope this helps !!! 希望这可以帮助 !!!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.