Installing Python 2.7 on Centos 6.5
2018-02-15 15:36
459 查看
url: https://gist.github.com/dalegaspi/dec44117fa5e7597a559
Centos 6.* comes with Python 2.6, but we can't just replace it with v2.7 because it's used by the OS internally (apparently) so you will need to install v2.7 (or 3.x, for that matter) along with it. Fortunately, CentOS made this quite painless with their Software Collections Repository
Owner
Centos 6.* comes with Python 2.6, but we can't just replace it with v2.7 because it's used by the OS internally (apparently) so you will need to install v2.7 (or 3.x, for that matter) along with it. Fortunately, CentOS made this quite painless with their Software Collections Repository
sudo yum update # update yum sudo yum install centos-release-scl # install SCL sudo yum install python27 # install Python 2.7To use it, you essentially spawn another shell (or script) while enabling the newer version of Python:
scl enable python27 bashTo install additional libraries, you will need to install PIP:
cd /opt/rh/python27/root/usr/bin/ # cd to the directory where SCL installs python sudo LD_LIBRARY_PATH=$LD_LIBRARY_PATH ./easy_install-2.7 piponce installed, you can install PIP using
pip2.7, e.g.:
sudo LD_LIBRARY_PATH=$LD_LIBRARY_PATH ./pip2.7 install requestsNOTE: if your username doesn't require root to install software, then
LD_LIBRARY_PATHand
PATHis set up for you automatically by
scl. Also keep in mind that using SCL outside a shell (e.g., cronjobs) isn't quite straightforward. Also, using
virtualenvposes a challenge as well.
codeAshu commented on 20 Mar 2016
Did you miss yum install -y python27 |
crayzeewulf commented on 16 Jun 2016
As @codeAshu mentioned, I had to use slightly modified instructions to install Python 2.7. Please see the updated gist in this fork and the differences here. Feel free to merge it. |
Owner
dalegaspi commented on 27 Jun 2016
i didn't see these messages (there should be notifications support for gists...) until i randomly wandered into this specific gist...thanks @crayzeewulf...i've merged your changes. |
MarcGodard commented on 25 Mar 2017 •
editedGetting error: Not a recognized archive type: pipon step sudo LD_LIBRARY_PATH=$LD_LIBRARY_PATH ./easy_install-2.7 pipHowever, it is working so it looks like it is already there. |
sonicwong commented on 19 Jun 2017
same here, got error in last step:[root@server bin]# sudo LD_LIBRARY_PATH=$LD_LIBRARY_PATH ./easy_install-2.7 pip /opt/rh/python27/root/usr/bin/python2: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory |
cbsdtools commented on 14 Sep 2017
I received the same error as @sonicwong |
alanthing commented on 19 Sep 2017
@cbsdtools and @sonicwong -- try this instead:Because the python27SCL comes via the centos-release-scl-rhpackage, you can install pip with: yum install python27-python-pip.If it may be helpful to know more about how to use SCLs, here is how the command from @sonicwong would be run with all of the proper environment variables set: scl enable python27 "easy_install-2.7 pip" scl enable python27 cmdwill effectively sourcethe contents of /opt/rh/python27/enablebefore running the cmd. If the command has arguments, you can wrap it in quotes.Alternatively, by running scl enable python27 bash, you can jump into a new bash session with PATH, LD_LIBRARY_PATH, MANPATH, XDG_DATA_DIRS, and PKG_CONFIG_PATHto run multiple consecutive commands without the scl enableprefixes . |
JSoet commented on 2 Oct 2017 •
editedWhen running pip I ran into a problem with permissions, it gave me this error any time I tried do any pip command:$ ./pip2.7 -V Traceback (most recent call last): File "./pip2.7", line 7, in <module> from pip import main File "/opt/rh/python27/root/usr/lib/python2.7/site-packages/pip/__init__.py", line 21, in <module> from pip._vendor.requests.packages.urllib3.exceptions import DependencyWarning ImportError: No module named requests.packages.urllib3.exceptionsI found out that this was due to permissions problems on the lib folders. To fix it I had to add the read and execute permissions to the python lib and lib64 folders like: sudo chmod -R o+rx /opt/rh/python27/root/usr/lib/python2.7/site-packages |
相关文章推荐
- How to Install Python 2.7 on CentOS6.5
- [转]Installing python 2.7 on centos 6.3. Follow this sequence exactly for centos machine only
- Python 2.7 install on centos 6.5
- Installing python 2.7 on centos 6.3.
- CENTOS 6.5 安装 Python 2.7 总结
- CentOS6.5 安装Python2.7后, yum出现“No module named yum”错误
- CentOS6.5上配置Python2.7+OpenCV2.4.7
- CentOS6.5安装Python2.7和Pip
- Install Python 3 on CentOS 6.5 Server
- centos6.5 升级python2.6到python2.7
- How To Install Python 2.7 with mod_wsgi on CentOS 5.6 with cPanel
- CentOS6.5 升级 Python 2.7 版本
- CentOS6.5安装Python2.7和Pip
- 在centos6.5环境下搭建多版本python(python2.6、python2.7、python3.5)共存环境
- CentOS 6.5升级Python2.7
- CentOS6.5自带Python2.6.6升级至Python2.7
- CentOS6.5上安装Python2.7和PIP
- centos6.5将python2.6.6升级到python2.7以及easy_install和pip
- Centos6.5 Python2.7+Supervisor 环境安装
- CentOS6.5上安装Python2.7和PIP