简体   繁体   中英

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. I installed different modules with pip3 , like Flask-SQLAlchemy, Flask-Migrate, etc. Everything worked perfectly.
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.

The solution is to install all these modules again but with pip (not pip3). Uninstallation/Installation with pip3 does not help. Why did it happen? Is it possible to turn it back to pip3?

I didn't change the environment, I have the only one actually. Using 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.

Here is a good official tutorial on how to use virtual environments

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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