目录

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

目录

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

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

/usr/local/lib

安装python3.6

下载python3.6.4

wget

解压

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/