Pycharm cannot import math module

2019-07-12 02:18发布

问题:

I can't import standard math module in pycharm, I'm getting an error: "No module named math", from python shell I can import it, what can cause that?

回答1:

Check that you are pointing to the correct python file within Settings > Project > Project Interpreter.

When I've had this problem in the past my interpreter was pointing at python3.6 and not python within the bin folder of my venv. I simply dropped the interpreter and added it again pointing to the venv-name/bin/python



回答2:

File >> Settings >> Project interpreter. You should see a list of currently installed packages/libraries. If the module is not specified in there click the plus sign and look for your module in there. Also make sure you specify it correctly when you import it.



回答3:

I had a similar issue and was able to fix it by creating a new Python system interpreter. Project Interpreter -> Add Local -> System Interpreter -> /usr/local/bin/python3