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?
Related
Installed miceForest with !pip install miceforest and no issue with installation
Collecting miceforest
Downloading miceforest-5.2.0-py3-none-any.whl (69 kB)
Requirement already satisfied: numpy in c:\programdata\anaconda3\lib\site-packages (from miceforest) (1.20.1)
Collecting lightgbm>=3.3.1
Downloading lightgbm-3.3.1-py3-none-win_amd64.whl (1.0 MB)
Requirement already satisfied: wheel in c:\programdata\anaconda3\lib\site-packages (from lightgbm>=3.3.1->miceforest) (0.36.2)
Requirement already satisfied: scikit-learn!=0.22.0 in c:\programdata\anaconda3\lib\site-packages (from lightgbm>=3.3.1->miceforest) (0.24.1)
Requirement already satisfied: scipy in c:\programdata\anaconda3\lib\site-packages (from lightgbm>=3.3.1->miceforest) (1.6.2)
Requirement already satisfied: joblib>=0.11 in c:\programdata\anaconda3\lib\site-packages (from scikit-learn!=0.22.0->lightgbm>=3.3.1->miceforest) (1.0.1)
Requirement already satisfied: threadpoolctl>=2.0.0 in c:\programdata\anaconda3\lib\site-packages (from scikit-learn!=0.22.0->lightgbm>=3.3.1->miceforest) (2.1.0)
Installing collected packages: lightgbm, miceforest
Successfully installed lightgbm-3.3.1 miceforest-5.2.0
No issue with below code
import miceforest as mf
from sklearn.datasets import load_iris
import pandas as pd
import numpy as np
But getting error while referring to MultipleImputedKernel
-------------------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-10-b346f2744b14> in <module>
----> 1 kernel = mf.MultipleImputedKernel(
2 iris_amp,
3 datasets=4,
4 save_all_iterations=True,
5 random_state=1991
AttributeError: module 'miceforest' has no attribute 'MultipleImputedKernel'
-------------------------------------------------------------------------------
Any help to fix the issue will be greatly appreciated
New main classes (ImputationKernel, ImputedData) have replaced (KernelDataSet, MultipleImputedKernel, ImputedDataSet, MultipleImputedDataSet).
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 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
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.