升级的Python;我必须手动重新安装所有站点软件包吗? [英] Upgraded Python; Do I have to reinstall all site-packages manually?

查看:202
本文介绍了升级的Python;我必须手动重新安装所有站点软件包吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近升级了我的Linux发行版. Python 3.5替换为Python 3.6.

I have upraded my Linux distro recently. Python 3.5 was replaced by Python 3.6.

我用pip3安装的所有站点程序包仍在/usr/lib/python3.5/site-packages目录中,而Python现在找不到它们,因为它显然在.../python3.6/site-packages中.

All site packages I have installed with pip3 are still in the /usr/lib/python3.5/site-packages directory and Python does not find them there now, because it looks in .../python3.6/site-packages obviously.

我看到了目录内容,可以再次手动安装它们,但是在我看来,这不像正确的安装方式.我可以将内容移动到新目录中,但是再次,在我看来这也不正确.

I see the directory contents and I could manually install them again, but that does not look to me like the right way to do it. I could move the contents to the new directory, but again, this seems to me incorrect either.

我应该如何正确处理?

在升级之前,我应该准备一个pip3 freeze列表吗?

Should I have prepared a pip3 freeze list before the upgrade?

我尝试搜索,但是关键字可能太笼统,并且得到了许多不相关的答案.

推荐答案

Python 3.5替换为Python 3.6.但是您仍然可以使用python 3.5进行备份.

Python 3.5 was replaced by Python 3.6. But you still have the backup option of using python 3.5.

如果要使用python 3.6,则必须重新安装python 3.6的所有pip软件包.而且很有道理.

If you want to use python 3.6 you will have to reinstall all pip packages again for python 3.6. And it makes sense.

假设您从2.7更改为3.5.您可能希望分别保存两个环境.因此3.6环境不同于3.5环境.

Say you were changing from 2.7 to 3.5. You would want to preserve both the environments separately. Hence 3.6 environment is different from 3.5.

执行此操作的一种快速方法是在pip freeze中安装3.5,然后在3.6中安装这些依赖.

A quick way to do this would be to pip freeze for 3.5 and then install those dependencies for 3.6.

pip freeze > reqs.txt

升级

pip install -r reqs.txt

由于您不再具有此选项,因此请先尝试在python3.5中列出所有软件包

Since you don't have this option anymore, first try and list all packages in your python3.5

为此,您可以按照@kabanus的回答安装pip3.5.

for that you can install pip3.5 as answered by @kabanus.

sudo apt-get install python3=3.5.1*
sudo python3.5 easy_install.py pip

此外,建议每个项目使用虚拟环境,以便您可以为每个虚拟环境维护单独的环境.

Also it's advised to use virtual environment per project so you can maintain separate environments for each of them.

这篇关于升级的Python;我必须手动重新安装所有站点软件包吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆