Home > Mobile >  PyCharm cannot find module from pip install
PyCharm cannot find module from pip install

Time:04-23

I installed the module with the command: pip install matplotlib. However, PyCharm does not find the module I installed.

# importing the required module
import matplotlib.pyplot as plt

# x axis values
x = [1,2,3]
# corresponding y axis values
y = [2,4,1]

# plotting the points
plt.plot(x, y)

# naming the x axis
plt.xlabel('x - axis')
# naming the y axis
plt.ylabel('y - axis')

# giving a title to my graph
plt.title('My first graph!')

# function to show the plot
plt.show()

Error

CodePudding user response:

The problem is that you install the matplotlib globally instead of in your current virtual environment. There are 2 ways to fix this:

  1. Activate your virtual environment in your command prompt first, then run the pip install command.
  2. Manage your packages via PyCharm package manager. Make sure that you set up the interpreter correctly.

I usually go with option 2 since it's easier that way.

CodePudding user response:

I saw your attached image. I think the matplotlib is getting installed on the system python version but not on the python version installed on the Pycharm.

To install the matplotlib on the pycharm's python version you have to open Pycharm terminal and run the pip install matplotlib

CodePudding user response:

first thing first you need to restart your idle to apply the package changes. second thing second you made an environment and you are running your project from it to fix it ether install matplotlib in environment that you created using venv or stop using the venv so your idle can access to main python files installed on your c drive if you are a little bit search for venv python in YouTube you'll get what I say

  • Related