How to install module for python 2.6 on CentOS?

After installing python 2.6 on CentOS using:

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:

  yum install pyPdf 

However, pyPdf is only available for old 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 is not available for a new installation of 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 to install pyPdf for python 2.6?

+3
source share
4 answers

How to create virtualenv and install pyPdf using pip

 $ curl -O https://pypi.python.org/packages/source/v/virtualenv/virtualenv-XXtar.gz $ tar xvfz virtualenv-XXtar.gz $ cd virtualenv-XX $ python26 virtualenv.py myVirtualenv $ source myVirtualenv/bin/activate $ pip install pyPdf 

Read more about virtualenv here

+1
source

Not sure how you do it. I recently installed pyPdf for CentOS for Python 2.7. A simple yuma worked for me.

yum install pyPdf

pyPdf is also available for newer versions. Check here

Edit:

There may be a problem with two different versions of Python for you. CentOS comes with a default installation of v2.4. Remove all previous versions and install again.

0
source

For CentOS versions below 6, python 2.4 is used by default. For version 6 and above, its python2.6.

Now, I would strongly advise against updating the base installation of Python ie python2.4 in earlier versions, as this would disrupt system-level functionality that expects python to be 2.4 by default.

Your question can be solved in several ways:

  • yum install always installs for python by default. If its 2.4 install the package for 2.4.
  • To install the package for version 2.6, download easy_install for 2.6 or PIP for version 2.6, and then simply run easy_install {{package_name}} or select {{package_name}}
  • To make your environment different, as @Dikei suggested, install virtual env and then install your packages. This method is one of the best practices for supporting multiple python environments.
0
source

Quick Python installation !!!

Get the latest version of Python 2.6.9

 wget https://www.python.org/ftp/python/2.6.9/Python-2.6.9.tar.xz 

Remove the thae package

 tar xf Python-2.6.9.tar.xz 

Customize them

 cd Python-2.6.9 ./configure --prefix=/usr/local --enable-unicode=ucs4 --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib" 

Set them

 make && make altinstall 

Check version:

 python --version Python 2.6.9 

Credits : https://danieleriksson.net

Hope this helps !!!

0
source

Source: https://habr.com/ru/post/1204113/


All Articles