No module named livelossplot - python

I have recently tried to make some realtime plots for my Ml models.
I have installed livelossplot through this command:
pip install livelossplot
But, when trying to import the module in Jupyter, it returns error:
ModuleNotFoundError: No module named 'livelossplot'
Please,
can someone help me?

You can try this
pip install livelossplot==0.1.2
Refer the below link
https://pypi.org/project/livelossplot/0.1.2/
If it doesn't work then you can clone the below repository
https://github.com/stared/livelossplot

Well there are a couple of ways to go about this problem one way is to start anaconda-navigator
left click on the play type button there in the (base)root environment and select open in terminal
and then simply type
pip install livelossplot
One another method is if you have added anaconda path to you PATH variable in linux or environment variable in WINDOWS then you can log into the environment
like
albin#computer:~$ source activate
(base) albin#computer:~$ pip install livelossplot
if you havent added to the PATH or environment variable then you can log into the enviroment by specifying the full path like
albin#computer:~$ source anaconda3/bin/activate
(base) albin#computer:~$ pip install livelossplot

Related

pip install cmd but modules not found in PyCharm

So, I have Pycharm and pip up to date, and after installing any module with pip install, no matter where I install it (/current_python_project) or somewhere else (\python310\lib\site-packages)...
When I pip install let's say pandas, and then try
import matplotlib.pyplot as plt
console says: ModuleNotFoundError: No module named 'matplotlib'
This happens with other packages here the package is installed but modules or ".py" files form installation, are not found.
Thank you!
I tried installing in different folders and changing virtual environment setting to all possible combinations but yet, I still can't fix the problem...
Checked docents of "answers" to similar problems
Also I checked one more answer here it says I have to install in env/bin/python but I searched for all folders containing "env" and apparently I don't have this folder....
Please try the following instructions:
python -m pip install – upgrade pip
pip install pandas
pip install matplotlib
Or you can try following instructios:
open cmd, and type "where python". Once you have opened the Python folder, browse and open the Scripts folder and copy its location. Also verify that the folder contains the pip file.Now open the Scripts directory in the command prompt using the cd command and the location that you copied previously.Now install the library using pip install matplotlib command. If it looks complicated please follow this link, they show with illustrations: https://blog.finxter.com/fixed-modulenotfounderror-no-module-named-matplotlib/

No module named 'keras_tuner' even though i installed it

i'm working on a classifier that uses CNN and i need to use the keras tuner so i can find the best CNN architecture
i executed this command "pip install keras-tuner" and it was installed successfully
but when i import it "import keras_tuner as kt" and run the python script
No module named 'keras_tuner'
i'm working offline with python 3.7.9,tensorflow 2.0,keras 2.7 in VSCode
can someone help me? i really need to use the tuner
thanks
so i used
pip install keras_tuner
in VSCode and the packge was really installed but in the global site-packages folder and not in venv/lib folder
so all i did is that i went to venv/pyvenv.cfg file in VSCode
and set
include-system-site-packages = true
I had the same issue using PyCharm. When I installed the keras-tuner package in the Anaconda 3 prompt, I got the message that everything is already installed. The problem was, that the keras-tuner was installed in my base environment and not in the environment (virtual) which I use in PyCharm. You simply need to do the following.
check out your environments in the anaconda prompt using: conda env list
you will probably see the * on the base environment
now change to your working environment for example conda activate tf_cpu -> tf_cpu needs to be changed by your envs name (see on your list)
install your package such as pip install keras_tuner

jupyter ModuleNotFoundError: No module named matplotlib

I am currently trying to work basic python - jupyter projects.
I am stuck on following error during matplotlib:
screenshot on jupyter-error
ModuleNotFoundError: No module named 'matplotlib'
I tried to update, reinstall matplotlib aswell in conda and in pip but it still not working.
happy over every constructive feedback
In a Notebook's cell type and execute the code:
import sys
!{sys.executable} -m pip install --user matplotlib
and reload the kernel
(src: http://jakevdp.github.io/blog/2017/12/05/installing-python-packages-from-jupyter/ )
open terminal and change the directory to Scripts folder where python installed. Then type the following command and hit enter
pip install matplotlib
Hope this will solve the issue.
I was facing the exact issue. It turns out that it was using the system Python version despite me having activated my virtual environment.
This is what eventually worked.
If you are using a virtual environment which has a name say myvenv, first activate it using command:
source activate myvenv
Then install module ipykernel using the command:
pip install ipykernel
Finally run (change myvenv in code below to the name of your environment):
ipykernel install --user --name myvenv --display-name "Python (myvenv)"
Now restart the notebook and it should pick up the Python version on your virtual environment.
While #Frederic's top-voted solution is based on JakeVDP's blog post from 2017, it completely neglects the %pip magic command mentioned in the blog post. Since 2017, that has landed in mainline IPython and the easiest way to access the correct pip instance connected to your current IPython kernel and environment from within a Jupyter notebook is to do
%pip install matplotlib
Take a look at the list of currently available magic commands at IPython's docs.
generally speaking you should try to work within python virtual environments. and once you do that, you then need to tell JupyterLab about it. for example:
# create a virtual environment
# use the exact python you want to work with in this step
python3.9 -m venv myvenv
# 'activate' (or 'enter') it
source myvenv/bin/activate
# install the exact stuff you want to use in that environment
pip install matplotlib
# now tell JupyterLabs about the environment
python -m ipykernel install --user --name="myenv" --display-name="My project (myenv)"
# start it up
jupyter notebook mynotebook
# if you now look under 'Kernel->Change kernel', your 'myenv' should be there
# select it (restart kernel etc if needed) and you should be good
The issue with me was that jupyter was taking python3 for me, you can always check the version of python jupyter is running on by looking on the top right corner (attached screenshot).
When I was doing pip install it was installing the dependencies for python 2.7 which is installed on mac by default.
It got solved by doing:
> pip3 install matplotlib
Having the same issue, installing matplotlib before to create the virtualenv solved it for me. Then I created the virtual environment and installed matplotlib on it before to start jupyter notebook.
in jupter notebook type
print(sys.executable)
this gave me the following
/Users/myusername/opt/anaconda3/bin/python
open terminal, go into the folder
/Users/myusername/opt/anaconda3/bin/
type the following:
python3 -m pip install matplotlib
restart jupyter notebook (mine is vs code mac ox)
If module installed an you are still getting this error, you might need to run specific jupyter:
python -m jupyter notebook
and this is also works
sudo jupyter notebook --allow-root

Package installed by Conda, Python cannot find it

I try to install Theano by Anaconda. It works, but when I enter the python -i, import theano shows No module named 'theano'. Do I need to switch another interpreter of Python, how? Also, for the packages installed by conda, if I don't double install them, can I find in Python? How is Python related to Python by Anaconda? Thanks!!!
I had have a similar issue, trying to install folium. If you are using the Anaconda:
When you install using conda install -c conda-forge folium, the package will be placed in:
./anaconda3/envs/[name env]/lib/python3.7/site-packages/folium
When you install using pip (with a anaconda env activated), pip install folium, the package will be placed in:
./anaconda3/lib/python3.7/site-packages/folium
Python use first the sites-packages as the target directory of manually built python packages. When you build and install python packages from source (using distutils, probably by executing python setup.py install ), you will find the installed modules in site-packages by default.
In this case you have two places: /anaconda3/lib/python3.7/site-packages/ and /anaconda3/envs/[name env]/lib/python3.7/site-packages/.
First the modules will be available as default in /anaconda3/lib/python3.7/site-packages/. Sometimes (and I really don't know why) the modules inside sites-packages conda env are not available to import automatically without export the PATH.
So, to solve this issue, you have 2 options:
Installing using pip install folium and import folium (don't need install by conda install), or
After conda install , run conda init, close the terminal and open a new one. So, try to import again.
Here are some tips about use a pip in a conda-environment.
You can refer to a specific version of python by using the following at the first line of your .py file
This is for python 2.7
#!/usr/bin/env python2.7
This is for python 3
#!/usr/bin/env python3
As other users already pointed out you need to check if your module is included in your sys path. Use code:
import sys
print(sys.path)
If not you can include this in your sys.path by using the command:
sys.path.append('/path/to/the/folder/of/your/module/file')
or place it in default PYTHONPATH itself.
Other great answers:
https://stackoverflow.com/a/19305076/5381704
The problem is that in the code editor you are using, you are running the default interpreter. Based on your code editor, change the python interpreter to the conda interpreter and it will work.
In my case that happened because conda screwed up the environment variables. Instead of using env-specific python and pip, it used the globally installed ones.
Solution:
conda deactivate your-env
conda activate your-env
In my workstation, I was able to solve No module named <module name> error using two different ways.
First method, I solved this temporarily by:
(1) Open a Terminal
(2) $ conda activate <Conda environment name>
(3) $ export PYTHONPATH=/home/<user name>/anaconda3/envs/<Conda environment name>/lib/<Python package version>/site-packages:$PYTHONPATH
It is a temporary solution. Whenever you run your virtual environment, you have to do this.
My runtime environment:
    OS: Unbuntu 18.04
    Conda version: 4.8.2
    Conda-build version: 3.18,11
    Python version 3.7.6.final.0
Second method, I removed the
alias python=/usr/bin/python3.6 line in bashrc file.
Somehow this line blocks using Python tools installed in Anaconda Virtual Environment if the Python version in the Virtual Environment is different.

cv2 import error on Jupyter notebook

I'm trying to import cv2 on Jupyter notebook but I get this error:
ImportError: No module named cv2
I am frustrated because I'm working on this simple issue for hours now. it works on Pycharm but not on Jupiter notebook. I've already installed cv2 into Python2.7's site packages, configured Jupyter's kernel to python2, browsed the documentation but I still don't get what I am missing ?
(I'm using windows 10 and working with microsoft cognitives api, that's why I need to import this package.)
here is the code:
<ipython-input-1-9dee6ed62d2d> in <module>()
----> 1 import cv2
2 cv2.__version__
What should I do in order to make this work ?
Is your python path looking in the right place? Check where python is looking for the module. Within the notebook try:
import os
os.sys.path
Is the cv2 module located in any of those directories? If not your path is looking in the wrong place. If it is overlooking the install location, append it to your python path. You can follow the instructions here.
I didn't have the openCV installation in my Python3 kernel, so I installed it by activating the specific environment and running this in the command prompt:
pip install opencv-python
How to find and activate my environment?
To list all of Your conda environments, run this command:
conda info --envs
You will get something like this:
ipykernel_py2 D:\Anaconda\envs\ipykernel_py2
root D:\Anaconda
After that, activate the environment that is complaining for the missing cv2 and run the pip install opencv-python command.
How to activate an environment?
Just run the command:
activate env_name
where env_name is the wanted environment (for example, You could type activate ipykernel_py2 if You wanted to access the first of the two environments listed above).
Note: If You are on Linux, You need to type source activate env_name.
Go to your notebook, in menu section
kernel -> Change kernel -> Python<desired version>
Now in the notebook run following command to install opencv2 in the selected environment kernel
python2:
!pip install opencv-python
python3:
!pip3 install opencv-python
Binmosa's explanation is great and to the point. As an alternative (easier, but I'm pretty sure it's just a band-aid fix), if you write:
import sys
!{sys.executable} -m pip install opencv-python
directly into your notebook, you'll be able to actually install the module in the notebook itself.
The longer explanation is interesting and informative, though. Link: https://jakevdp.github.io/blog/2017/12/05/installing-python-packages-from-jupyter/
To make this clear for those who are having the same issue:
By default: Anaconda (jupyter notebook) has its own version of Python & packages once it has been installed on your PC.
If you have Python x.x installed on your PC, and you installed OpenCV or -whatever packages- using the package manager of this python version, it does NOT mean your jupyter notebook will get access to these python packages you installed earlier. They are not living in the same folder.
To illustrate this, open your windows CMD and write :
python
then write:
import os
os.path
you will get the path of your python. in my case (C:\Python35)
Now open the Anaconda Prompt and write the same commands again:
you will get the anaconda's python path. In my case (C:\Users\MY_NAME\Anaconda3).
As you can see, there are two different paths of python, so make sure that your first step in diagnosing such error (No module named x) is to ask yourself whether you installed the package in the right place or not!
N.B: within Anaconda itself you can create environments, each environment may have different packages installed in it, so you also have to make sure you're in the right environment and it is the active one.
It is because of opencv library.
Try running this command in anaconda prompt:
conda install -c conda-forge opencv
You can simply open Jupyter Notebook and in any of the cell, just write:
pip install opencv-python
It will automatically install the file
Note : Keep turn ON your Internet connection
Then in next cell :
import cv2
It will work.
I added \envs\myenv\Library\bin also in the path variable and it got solved.
You will need to install ipykernel for the jupyter notebook. Follow the following steps:
python -m virtualenv env
source env/bin/acitivate
pip install opencv-contrib-python
pip install ipykernel --upgrade
python -m ipykernel install --user
jupyter notebook
You can simply try this in your jupyter notebook cell `%pip install opencv-python`
no matter which python version you're using. you may need to restart kernel to use updated package
I had this issue in my Jupyter Notebook after I had "installed" the opencv package, using Anaconda Navigator, on my base (root) environment.
However, after "installing" the package and its dependencies, Anaconda Navigator showed a reminder popup to update to the next Anaconda Navigator version. I ignored this at first, but couldn't use the opencv package in my Jupyter Notebook.
After I did update Anaconda Navigator to the newer version, the opencv package install worked fine.
pip install opencv-python
This solved the error for me in MacOS.
I had similar problem. None of the above solution worked for me. I did below in my notebook and that solved the issue
!pip install opencv-python
!pip install opencv-python-headless
I hope you have already activated the environment you know OpenCV is installed in but is not running/import error in jupyter notebook.
If not then run the below command and activate your environment before running the jupyter notebook.
conda activate /Users/prajendr/anaconda3/envs/cvpy39
Then, check all the anaconda environments on your machine using the below command on the jupyter notebook.
!conda info --envs
The output would be similar -
Try to install OpenCV in the environment again.
You know that you have OpenCV installed in this anaconda environment - cvpy39 and the path is "/Users/prajendr/anaconda3/envs/cvpy39/lib/python3.9/site-packages"
Then type the below commands to see if the OpenCV path was imported in the notebook or not?
import os
os.sys.path
you see the OpenCV path is not in this list so you need to manually import it.
Then in a cell type the below set of code. Make sure to change the python path of the environment to yours.
import sys
path_to_module = "/User/prajendr/anaconda3/envs/cvpy39/lib/python3.9/site-packages/"
sys.path.append(path_to_module)
import cv2
You will now be able to import OpenCV to your jupyter notebook.
One of possibility is that you could have written import cv2 and its utilisation in separate cells of jupyter notebook.If this is the case then first run the cell having import cv2 part and then run the cell utilising the cv2 library.

Categories

Resources