Linux下Python3安装

1. 安装python3.6可能使用的依赖

#yum -y install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel 
#yum -y install gcc*

 

2. 把Python3.6安装到 /usr/local 目录

# tar -xzvf Python-3.6.1.tgz  
# cd Python-3.6.1/

#
./configure --prefix=/usr/local/ # make # make altinstall #兼容性 python3.6程序的执行文件:/usr/local/bin/python3.6 python3.6应用程序目录:/usr/local/lib/python3.6 pip3的执行文件:/usr/local/bin/pip3.6 pyenv3的执行文件:/usr/local/bin/pyenv-3.6

 

179 Installing multiple versions
180 ----------------------------
181 
182 On Unix and Mac systems if you intend to install multiple versions of Python
183 using the same installation prefix (``--prefix`` argument to the configure
184 script) you must take care that your primary python executable is not
185 overwritten by the installation of a different version.  All files and
186 directories installed using ``make altinstall`` contain the major and minor
187 version and can thus live side-by-side.  ``make install`` also creates
188 ``${prefix}/bin/python3`` which refers to ``${prefix}/bin/pythonX.Y``.  If you
189 intend to install multiple versions using the same prefix you must decide which
190 version (if any) is your "primary" version.  Install that version using ``make


#位置:
[root@localhost Python-3.6.1]# pwd
/usr/src/Python-3.6.1
[root@localhost Python-3.6.1]# vim README.rst 
191 install``.  Install all other versions using ``make altinstall``.
192 
193 For example, if you want to install Python 2.7, 3.5, and 3.6 with 3.6 being the
194 primary version, you would execute ``make install`` 
make altinstall

 

3. 更改/usr/bin/python链接

# cd/usr/bin
# mv  python python.backup
# ln -s /usr/local/bin/python3.6 /usr/bin/python
# ln -s /usr/local/bin/python3.6 /usr/bin/python3

#rm -rf /usr/bin/python2 
#ln -s /usr/bin/python2.6 /usr/bin/python2 

 

4. 更改yum脚本的python依赖

# cd /usr/bin
# ls yum*
  yum yum-config-manager yum-debug-restore yum-groups-manager
  yum-builddep yum-debug-dump yumdownloader
更改以上文件头为
#!/usr/bin/python 改为 #!/usr/bin/python2

 

4.测试

[root@localhost ~]# python
    Python 3.6.1

 

 其它:

安装好了anaconda之后:
    可以用python自带的pip安装: pip install packagename
    也可以用anaconda提供的conda安装: conda install packagename 

  

posted @ 2018-04-24 20:52  shadow3  阅读(187)  评论(0)    收藏  举报