Recently, I was learning Python flask framework. After configuring the environment, I ran "hello.py" in the terminal. The effect was good. There was nothing wrong with it; but when I opened it with pycharm, I found that the code was wrong, and the Flask class could not be imported. The detailed error Message as follows:
This inspection detects names that should resolve but don't. Due to dynamic dispatch and duck typing,this is possible in a limited but useful number of cases. Top-level and class-level items are supported better than instance items.
Error details
This is the result of running the terminal
Terminal result
It took a long time to find a solution from Baidu on the Internet. Here is a summary. Hope to help you
First, open the terminal (click on the "Terminal" icon in the picture)
Open terminal
Then type in the terminal
pip install flask
Install flask
You're done
operation result
Note:
This solution is actually to reinstall flask on the pycharm terminal; but I don’t really understand why this is done. The package installed via pip in the Windows environment can be directly imported in pycharm, maybe Because this is the reason in the Linux environment, it may also be because when I configured the environment before, I configured the virtual environment. If anyone sees this blog, I hope they can give me advice and leave an answer in the comment area.
The above solution for pycharm unable to import classes under Ubuntu is all the content shared by the editor, I hope to give you a reference.
Recommended Posts