The Django project has ModuleNotFoundError: No module named "XXX" , the problem solution.

Question as title.

I have also been in touch with Django for a while, and it is normal to run the "python manage.py runserver" command without importing third-party libraries. But once the third-party library is imported, the start server command will report an error. The "XXX" in the title is the name of the third-party library. But it is clear that the third-party library is already installed.

Searching for answers on the Internet is fruitless, because this question is actually not related to my situation.

Solution: I finally found out that it was because the virtual environment was not turned on. Because third-party libraries are installed in virtual environments, and Django is only available in virtual environments. So just start the virtual environment in advance.

Enter "name(your virtual environment name)\Scripts\activate" at the command line

The problem that has been bothering me for more than a day is finally solved!

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325650380&siteId=291194637