I am new in Python and I have this sample code to test some libraries (I've installed all needed libraries with pip
).
import matplotlib.pyplot as plt
import numpy
myarray = numpy.array([1, 2, 3])
plt.plot(myarray)
plt.xlabel('some x axis')
plt.ylabel('some y axis')
plt.show()
when I run the code from command line (macOS) via command python main.py
I get chart as expected. Bud when I run the same code in Pycharm I get an error related to missing libraries.
/Users/jirka/PycharmProjects/sandbox/venv/bin/python /Users/jirka/PycharmProjects/sandbox/main.py Traceback (most recent call last): File "/Users/jirka/PycharmProjects/sandbox/main.py", line 2, in import matplotlib.pyplot as plt ModuleNotFoundError: No module named 'matplotlib'
Process finished with exit code 1
Q: What I have to set in Pycharm to find installed system libraries?
Edit: I just add to the accepted answer that the Python interpreter can be in Pycharm set globally for all projects.
Try file -> Settings -> Project : xxxx -> Python Interpreter Then change Python interpreter from venv to your local python.exe