1.system就是系统自带的python2.7.5
[suhong@localhost ~]$ pyenv versions* system (set by /home/suhong/.python-version)
anaconda3-4.1.1
2.切换至高版本
[suhong@localhost ~]$ pyenv local anaconda3-4.1.1(anaconda3-4.1.1) [suhong@localhost ~]$ python
Python3.5.2 |Anaconda 4.1.1 (64-bit)| (default, Jul 2 2016, 17:53:06)
[GCC4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits"or "license" formore information.>>>
3.切换至低版本
(anaconda3-4.1.1) [suhong@localhost ~]$ pyenv local system
[suhong@localhost ~]$ python
Python2.7.5 (default, Sep 15 2016, 22:37:39)
[GCC4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2
Type "help", "copyright", "credits"or "license" formore information.>>>
4.切换低版本后发现python2.7.5没有pip
1. 下载setuptools及pip的源码包
setuptools与pip都是python的模块
setuptools源码包: https://pypi.python.org/pypi/setuptools
pip源码包: https://pypi.python.org/pypi/pip#downloads
2. 安装setuptools与pip
目前下载的版本是setuptools-12.0.5.tar.gz与pip-6.0.6.tar.gz
用tar命令解压, 格式:tar -xzvf xxxx.tar.gz
用cd打开该文件夹,格式:cd xxxx
用python命令安装,格式:python setup.py install
3.本来照理在python安装package用命令格式:pip install xxxx
但出现错误,例如:pip install ipython
出现错误:
Exception:
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/pip-8.1.2-py2.7.egg/pip/basecommand.py", line 215, inmain
status=self.run(options, args)
File "/usr/lib/python2.7/site-packages/pip-8.1.2-py2.7.egg/pip/commands/install.py", line 317, inrun
prefix=options.prefix_path,
File "/usr/lib/python2.7/site-packages/pip-8.1.2-py2.7.egg/pip/req/req_set.py", line 742, ininstall**kwargs
File "/usr/lib/python2.7/site-packages/pip-8.1.2-py2.7.egg/pip/req/req_install.py", line 831, ininstall
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "/usr/lib/python2.7/site-packages/pip-8.1.2-py2.7.egg/pip/req/req_install.py", line 1032, inmove_wheel_files
isolated=self.isolated,
File "/usr/lib/python2.7/site-packages/pip-8.1.2-py2.7.egg/pip/wheel.py", line 346, inmove_wheel_files
clobber(source, lib_dir, True)
File "/usr/lib/python2.7/site-packages/pip-8.1.2-py2.7.egg/pip/wheel.py", line 317, inclobber
ensure_dir(destdir)
File "/usr/lib/python2.7/site-packages/pip-8.1.2-py2.7.egg/pip/utils/__init__.py", line 83, inensure_dir
os.makedirs(path)
File "/usr/lib64/python2.7/os.py", line 157, inmakedirs
mkdir(name, mode)
OSError: [Errno13] Permission denied: '/usr/lib64/python2.7/site-packages/pygments'
后来发现是权限问题,应该用“sudo pip install xxxx”,结果问题迎刃而解
5.安装scrapy,出现一些问题
compilation terminated.
error: command'gcc' failed with exit status 1
用安装Python模块出现error: command 'gcc' failed with exit status 1 ,明明装了gcc的,怎么会不行呢,然后发觉是failed不是not found,这说明这个错误个gcc没多大关系,应该是缺少某些功能模块,然后谷歌了一下,先后安装了python-devel,libffi-devel后还是不行,最后发觉要安装openssl-devel才行
可如下命令行安装:
yum install gcc libffi-devel python-devel openssl-devel
6.pip install MySQL-python(出现EnvironmentError: mysql_config not found)解决办法:安装包MySQL-devel-5.1.7-0.i386.rpmMySQL-shared-5.1.7-0.i386.rpm后,再次进行install就解决了机智的我只用了sudo yum install MySQL-devel就解决了