如何将所有模块移动到新版本的 Python(从 3.6 到 3.7) [英] How to move all modules to new version of Python (from 3.6 to 3.7)

查看:78
本文介绍了如何将所有模块移动到新版本的 Python(从 3.6 到 3.7)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚升级到 python 3.7 并且我意识到我的所有模块都停留在以前的版本中.甚至 Django 也不再被识别.我该怎么做才能将所有内容转移到新版本?我现在有点迷茫,不知道新版本安装在哪里.

I just upgraded to python 3.7 and I realized that all my modules stuck with the previous version. Even Django is not recognised anymore. How can I do to transfer everything to the new version? I am a little lost right now, don't even know where the new version has been installed.

当我执行 $ which python3.6 时,终端告诉我它不存在,但我在 /usr/中有一个 python3.6 目录local/lib/,所有模块都安装在这里.

When I do $ which python3.6 the terminal tells me it doesn't exist, but I have a python3.6 directory in /usr/local/lib/, where all modules are installed.

在同一个目录 /usr/local/lib/ 我也有一个 python3.7 目录,其中安装了一些模块,但很多都丢失了.但是,当我在查找器中搜索文件 python3.7 时,它没有出现.当我执行 $ which python3.7 时,路径是 /usr/local/bin 所以与目录的路径不同.

In the same directory /usr/local/lib/ I also have a python3.7 directory with some modules installed but many are missing. However when I search for the file python3.7 in my finder it doesn't appear. when I do $ which python3.7 the path is /usr/local/bin so not the same path as the directory.

有谁看到发生了什么,知道如何将所有模块转移到 python3.7?

Anyone sees what happened and knows how I can transfer all modules to python3.7?

推荐答案

即使删除了旧的python版本,也可以通过--path 选项来列出之前版本中安装的所有模块.

Even if the old python version has been removed, it is possible to use the pip of the current python version with the --path option to list all the modules installed in the previous version.

例如,将我所有用户安装的 python 模块从 3.7 迁移到 3.8

For example, migrating all my user installed python modules from 3.7 to 3.8

pip freeze --path ~/.local/lib/python3.7/site-packages > requirements.txt
pip install --user -r requirements.txt

顺便说一下,我总是使用 pip install--user 并将系统范围的安装留给我的 linux 发行版的包管理器.

Incidentally, I always use pip install with --user and leave the system wide installations to the package manager of my linux distro.

这篇关于如何将所有模块移动到新版本的 Python(从 3.6 到 3.7)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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