I am trying to import pyplot using given command but got error:
python -m pip install pyplot
Collecting pyplot
Could not find a version that satisfies the requirement pyplot (from versions: )
No matching distribution found for pyplot
Validated matplotlib and it is already imported:
pip install matplotlib
Requirement already satisfied: matplotlib in c:\users\kratica rastogi\pycharmprojects\mlmodelbuilding\venv\lib\site-packages (3.3.2)
Requirement already satisfied: cycler>=0.10 in c:\users\kratica rastogi\pycharmprojects\mlmodelbuilding\venv\lib\site-packages (from matplotlib) (0.10.0)
Requirement already satisfied: pillow>=6.2.0 in c:\users\kratica rastogi\pycharmprojects\mlmodelbuilding\venv\lib\site-packages (from matplotlib) (7.2.0)
Requirement already satisfied: kiwisolver>=1.0.1 in c:\users\kratica rastogi\pycharmprojects\mlmodelbuilding\venv\lib\site-packages (from matplotlib) (1.2.0)
Requirement already satisfied: certifi>=2020.06.20 in c:\users\kratica rastogi\pycharmprojects\mlmodelbuilding\venv\lib\site-packages (from matplotlib) (2020.6.20)
Requirement already satisfied: numpy>=1.15 in c:\users\kratica rastogi\pycharmprojects\mlmodelbuilding\venv\lib\site-packages (from matplotlib) (1.19.2)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.3 in c:\users\kratica rastogi\pycharmprojects\mlmodelbuilding\venv\lib\site-packages (from matplotlib) (2.4.7)
Requirement already satisfied: python-dateutil>=2.1 in c:\users\kratica rastogi\pycharmprojects\mlmodelbuilding\venv\lib\site-packages (from matplotlib) (2.8.1)
Requirement already satisfied: six in c:\users\kratica rastogi\pycharmprojects\mlmodelbuilding\venv\lib\site-packages (from cycler>=0.10->matplotlib) (1.15.0)
How to install pyplot in pycharm?
I think what you want to do is import matplotlib.pyplot as plt in your code.
# test.py
import matplotlib.pyplot as plt
def your_function1():
pass
you needn't install pyplot. because pyplot is a part of matplotlib module.
pyplot is part of matplotlib, so when you install matplotlib with pip install matplotlib, all you have to do is import pyplot in your python file.
# example.py
from matplotlib import pyplot as plt
Related
When I type import seaborn as sns on jupyter and on VScode, it always happens ModuleNotFoundError.
I have already did pip install seaborn in my terminal.
Has someone a solution? Thank you in advance
PS
I have already done install seaborn in terminal
pip install seaborn
Requirement already satisfied: seaborn in c:\python39\lib\site-packages (0.11.1)
Requirement already satisfied: scipy>=1.0 in c:\python39\lib\site-packages (from seaborn) (1.6.3)
Requirement already satisfied: numpy>=1.15 in c:\python39\lib\site-packages (from seaborn) (1.20.3)
Requirement already satisfied: pandas>=0.23 in c:\python39\lib\site-packages (from seaborn) (1.2.4)
Requirement already satisfied: matplotlib>=2.2 in c:\python39\lib\site-packages (from seaborn) (3.4.2)
Requirement already satisfied: pytz>=2017.3 in c:\python39\lib\site-packages (from pandas>=0.23->seaborn) (2021.1)
Requirement already satisfied: python-dateutil>=2.7.3 in c:\python39\lib\site-packages (from pandas>=0.23->seaborn) (2.8.1)
Requirement already satisfied: cycler>=0.10 in c:\python39\lib\site-packages (from matplotlib>=2.2->seaborn) (0.10.0)
Requirement already satisfied: pillow>=6.2.0 in c:\python39\lib\site-packages (from matplotlib>=2.2->seaborn) (8.2.0)
Requirement already satisfied: kiwisolver>=1.0.1 in c:\python39\lib\site-packages (from matplotlib>=2.2->seaborn) (1.3.1)
Requirement already satisfied: pyparsing>=2.2.1 in c:\python39\lib\site-packages (from matplotlib>=2.2->seaborn) (2.4.7)
Requirement already satisfied: six>=1.5 in c:\python39\lib\site-packages (from python-dateutil>=2.7.3->pandas>=0.23->seaborn) (1.16.0)
Numpy and pandas work.
Screen shot
Try
conda install seaborn
or
conda install -c conda-forge seaborn
I am trying to work with the TimeSynth Python package in my Conda environment. It is not available on the pkgs list or conda-forge list of Conda-supported packages, so I found this post that seems to get around the issue by installing the package in the Conda environment using pip.
I followed the instructions in the accepted answer, however when I do the last step:
.conda/envs/tcl/bin/pip install timesynth
(tcl is the name of my environment)
It says the requirement is already satisfied:
Requirement already satisfied: timesynth in
./.conda/envs/tcl/lib/python3.6/site-packages (0.2.4)
Requirement already satisfied: scipy in
./.conda/envs/tcl/lib/python3.6/site-packages (from timesynth) (1.4.1)
Requirement already satisfied: jitcxde-common==1.4.1 in
./.conda/envs/tcl/lib/python3.6/site-packages (from timesynth) (1.4.1)
Requirement already satisfied: numpy in
./.conda/envs/tcl/lib/python3.6/site-packages (from timesynth)
(1.18.1)
Requirement already satisfied: sympy in
./.conda/envs/tcl/lib/python3.6/site-packages (from timesynth) (1.8)
Requirement already satisfied: symengine==0.4 in
./.conda/envs/tcl/lib/python3.6/site-packages (from timesynth) (0.4.0)
Requirement already satisfied: jitcdde==1.4 in
./.conda/envs/tcl/lib/python3.6/site-packages (from timesynth) (1.4.0)
Requirement already satisfied: jinja2 in
./.conda/envs/tcl/lib/python3.6/site-packages (from
jitcxde-common==1.4.1->timesynth) (3.0.0a1)
Requirement already satisfied: setuptools in
./.local/lib/python3.6/site-packages (from
jitcxde-common==1.4.1->timesynth) (56.2.0)
Requirement already satisfied: MarkupSafe>=1.1 in
./.conda/envs/tcl/lib/python3.6/site-packages (from
jinja2->jitcxde-common==1.4.1->timesynth) (2.0.0)
Requirement already satisfied: mpmath>=0.19 in
./.conda/envs/tcl/lib/python3.6/site-packages (from sympy->timesynth)
(1.2.1)
However when I run a Python script that imports timesynth, it doesn't recognize the module. Any advice?
EDIT:
Per request, here is the start of the file I'm trying to use timesynth in:
import numpy as np
import TimeSynth.timesynth as ts
import matplotlib.pyplot as plt
import seaborn as sns; sns.set()
And the error cites line 2 and states:
ModuleNotFoundError: No module named 'TimeSynth'
Following the TimeSynth library's example, the import statement of OP
import TimeSynth.timesynth as ts
should instead be
import timesynth as ts
I can't seem to import matplotlib.
import matplotlib
ModuleNotFoundError: No module named 'matplotlib'
Trying conda list matplotlib give the following output:
# Name Version Build Channel
matplotlib 3.1.1 py37_1 conda-forge
matplotlib-base 3.1.1 py37h2852a4a_1 conda-forge
I tried to install it using pip: pip install matplotlib. It resulted in:
Requirement already satisfied: matplotlib in c:\programdata\anaconda3\envs\tf-gpu\lib\site-packages (3.1.1)
Requirement already satisfied: kiwisolver>=1.0.1 in c:\programdata\anaconda3\envs\tf-gpu\lib\site-packages (from matplotlib) (1.1.0)
Requirement already satisfied: numpy>=1.11 in c:\programdata\anaconda3\envs\tf-gpu\lib\site-packages (from matplotlib) (1.16.5)
Requirement already satisfied: python-dateutil>=2.1 in c:\programdata\anaconda3\envs\tf-gpu\lib\site-packages (from matplotlib) (2.8.0)
Requirement already satisfied: cycler>=0.10 in c:\programdata\anaconda3\envs\tf-gpu\lib\site-packages (from matplotlib) (0.10.0)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in c:\programdata\anaconda3\envs\tf-gpu\lib\site-packages (from matplotlib) (2.4.2)
Requirement already satisfied: setuptools in c:\programdata\anaconda3\envs\tf-gpu\lib\site-packages (from kiwisolver>=1.0.1->matplotlib) (41.4.0)
Requirement already satisfied: six>=1.5 in c:\programdata\anaconda3\envs\tf-gpu\lib\site-packages (from python-dateutil>=2.1->matplotlib) (1.12.0)
What should I do?
Edit: I later found that i could import it in my base env. But still can't do it in tf-gpu env
When I try to run my python script I get the following error
import matplotlib.pyplot as plt
ModuleNotFoundError: No module named 'matplotlib'
SO I tried to install Matplotlib using
"pip install matplotlib"
Then I get the error
Requirement already satisfied: matplotlib in
c:\users\harla\anaconda2\lib\site-packages
Requirement already satisfied: numpy>=1.7.1 in
c:\users\harla\anaconda2\lib\site-packages (from matplotlib)
Requirement already satisfied: six>=1.10 in
c:\users\harla\anaconda2\lib\site-packages (from matplotlib)
Requirement already satisfied: python-dateutil in
c:\users\harla\anaconda2\lib\site-packages (from matplotlib)
Requirement already satisfied: functools32 in
c:\users\harla\anaconda2\lib\site-packages (from matplotlib)
Requirement already satisfied: pytz in c:\users\harla\anaconda2\lib\site-
packages (from matplotlib)
Requirement already satisfied: cycler>=0.10 in
c:\users\harla\anaconda2\lib\site-packages (from matplotlib)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=1.5.6 in
c:\users\harla\anaconda2\lib\site-packages (from matplotlib)
I know I have installed anaconda. I don't want to use Anaconda for this. How do I install the library matplotlib ?
I solved it by removing the environment variable to C:\Users\harla\Anaconda2\Scripts_flag
Not sure if there is a better solution.
When I try to run matplotlib in my virtual env, this is what I get.
ImportError Traceback (most recent call last)
<ipython-input-1-d0b23255e9ca> in <module>()
1 import cv2
2 import numpy as np
----> 3 import matplotlib.pyplot as plt
4 #%matplotlib inline
ImportError: No module named 'matplotlib'
This is the output when I run, pip3 install matplotlib
Requirement already satisfied: pyparsing!=2.0.0,!=2.0.4,!=2.1.2,!=2.1.6,>=1.5.6 in ./.envs/opencv/lib/python3.5/site-packages (from matplotlib)
Requirement already satisfied: six>=1.10 in ./.envs/opencv/lib/python3.5/site-packages (from matplotlib)
Requirement already satisfied: cycler>=0.10 in ./.envs/opencv/lib/python3.5/site-packages (from matplotlib)
Requirement already satisfied: pytz in ./.envs/opencv/lib/python3.5/site-packages (from matplotlib)
Requirement already satisfied: numpy>=1.7.1 in ./.envs/opencv/lib/python3.5/site-packages (from matplotlib)
Requirement already satisfied: python-dateutil in ./.envs/opencv/lib/python3.5/site-packages (from matplotlib)
What am I missing?