简体   繁体   English

安装的 pip3 模块不再可识别。 需要用pip重新安装

[英]Installed with pip3 modules no longer recognizable. Need to reinstall with pip

I faced a strange issue: I'm working on a Python/Flask project on my local computer, don't use the virtual env.我遇到了一个奇怪的问题:我正在本地计算机上处​​理 Python/Flask 项目,不要使用虚拟环境。 I installed different modules with pip3 , like Flask-SQLAlchemy, Flask-Migrate, etc. Everything worked perfectly.我使用pip3安装了不同的模块,如 Flask-SQLAlchemy、Flask-Migrate 等。一切都运行良好。
Suddenly, after a few weeks, when running the program, it started to appear the errors, like ModuleNotFoundError: No module named 'flask_sqlalchemy' - and the same for Flask-Migrate, Flask-WTF, etc.突然,几周后,在运行程序时,它开始出现错误,例如ModuleNotFoundError: No module named 'flask_sqlalchemy' - Flask-Migrate、Flask-WTF 等也是如此。

The solution is to install all these modules again but with pip (not pip3).解决方案是再次安装所有这些模块,但使用pip (而不是 pip3)。 Uninstallation/Installation with pip3 does not help.使用 pip3 卸载/安装没有帮助。 Why did it happen?为什么会这样? Is it possible to turn it back to pip3?是否可以将其转回 pip3?

I didn't change the environment, I have the only one actually.我没有改变环境,我实际上只有一个。 Using Python 3.8使用 Python 3.8

I would say that the reason why it is like this, it's because maybe there is some libraries for other your projects that clash with flask libraries and that's why you have issues.我会说之所以会这样,是因为您的其他项目可能有一些库与烧瓶库发生冲突,这就是您遇到问题的原因。 Eg I had the same issue when I didn't use virtual environments when I was learning Python, and when I had multiple projects with different python libraries, some of them clashed and produced unexpected errors, so I started using virtual environments - different virtual environment for each project and it solved all the problems with clashes between different libraries.例如我在学习Python时没有使用虚拟环境时遇到了同样的问题,当我有多个项目使用不同的python库时,其中一些发生冲突并产生意外错误,所以我开始使用虚拟环境-不同的虚拟环境对于每个项目,它解决了不同库之间冲突的所有问题。

Here is a good official tutorial on how to use virtual environments这是一个关于如何使用虚拟环境的很好的官方教程

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM