Linux下安装python3.6并建立软连接

31 篇文章 0 订阅

乌班图的python2.7和python3.4安装位置

/usr/local/lib

 

安装python3.6

下载python3.6.4

wget https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tgz

解压

tar -zxvf Python-3.6.4.tgz

 

创建目录

sudo mkdir /usr/local/python3.6

 

编译安装(在解压出来的目录下执行)

建议make和make install 分两步

sudo ./configure --prefix=/usr/local/python3.6

sudo make

sudo make install

 

 

删除软链接

rm -rf /usr/bin/python3

rm -rf /usr/bin/pip3

 

 

建立新的指向python3.6的软链接

sudo ln -s /usr/local/python3.6/bin/python3.6 /usr/bin/python3

sudo ln -s /usr/local/python3.6/bin/pip3.6 /usr/bin/pip3

 

 

python3 查看

 

pip3 install 安装软件报错

报错:

/usr/local/python3.6/lib/python3.6/site-packages/pip/_vendor/distro.py

raise subprocess.CalledProcessError(code, cmd, stdout, stderr) subprocess.CalledProcessError: Co

 

**kwargs).stdout File "/home/lab/anaconda3/envs/python3/lib/python3.7/subprocess.py", line 487, in run output=stdout, stderr=stderr) subprocess.CalledProcessError: Command '('lsb_release', '-a')' returned non-zero exit status 1.

 

这里的问题主要出在 lsb_release 包上, 此处可通过修改conda中pip下的 distro.py , 编辑其初始化方法的 include_lsb属性为False.

 

stackoverflow - 解答:

I had the same problem on a shared hosting account

which is very limiting (I was installing python and pip for my user only).

Their lsb_release -a returns something non-standard

and I cannot change it.

I solved the issue by editing distro.py

(in your case: /usr/local/lib/python3.6/dist-packages/pip/_vendor/distro.py)

and changing the default parameter of __init__ method.

In my version it was at the line 545. Snippet: def __init__(self, include_lsb=True, os_release_file='', distro_release_file=''): Just change include_lsb=True to include_lsb=False.

 

即:

def __init__(self,

include_lsb=False,    # 这里把True改成False

os_release_file='',

distro_release_file='',

include_uname=True):

 

编辑这个报错的文件

sudo vim /usr/local/python3.6/lib/python3.6/site-packages/pip/_vendor/distro.py

 

把include_lsb的True改成False

include_lsb=False

 

 

 

第二个报错

The directory '/home/rongyi/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.

The directory '/home/rongyi/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.

 

解决方法如下:

sudo chown -R root /home/rongyi/.cache/pip/

sudo chown -R root /home/rongyi/.cache/pip/http/

 

  • 8
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值