Import OpenCV on jupyter notebook - python

I tried installing OpenCV on Windows 10 using pip.
I used this command-
pip install opencv-contrib-python
After that when I tried importing cv2 on command prompt, it was successfully imported-
When I tried importing it on jupyter notebook, this error popped up-
This is the python version I'm using-
This is pip list and as I've highlighted, opencv-contrib-python version 3.4.3.18 is installed-
Then why can't I import OpenCV on jupyter notebook, like tensorflow or numpy are also in pip list and I'm able to import them both through command prompt and also on jupyter notebook.
Please help. Thanks a lot.

You have installed openCV in Python running on your Terminal, not into the working environment which Jupyter Notebooks is running from.
Whilst in Terminal write:
py -m pip install opencv-python
When you use pip list
You should see opencv-python 3.4.3.18
More information here.

In the Anaconda Navigator. Launch conda console as below.
In the console: run conda install opencv

Try this in anaconda prompt:
First create a new enviorment :
conda create -n opencv
then :
conda activate opencv
then:
conda install -c anaconda opencv
source:youtube

You should open the anaconda prompt and then type:
conda install opencv
It should work.

It seems like you run jupyter not from conda environment, that has opencv module installed.
try to do this:
conda activate <your environment>
conda install jupyter
jupyter notebook
after that try to "import cv2"

Related

How install kmapper?

I have installed kmapper since command prompt, but when I import kmapper in jupyter notebook
is visualized a error: No module named kmapper.
What can I do?
I should install kmapper, please help me.
I don't see a Conda version for this in a major Anaconda Cloud channel. Install with pip.
conda create -n my_kmapper_env python pip numpy matplotlib scikit-learn bokeh pillow
conda activate my_kmapper_env
pip install kmapper

Installed a package on command line and can import it via command line. Receive ModuleNotFoundError when importing in jupyter notebook

I installed the python package lifelines on my terminal. The windows terminal is my terminal of choice, with a powershell and anaconda terminal that I often used.
I tried installing the package using the provided commands in the documentation:
pip install lifelines
and
conda install -c conda-forge lifelines
Both times the installation is marked as successfull. When I run Python within the terminal I can import the lifelines package without problem. However whem I import it on a jupyter notebook it yields a ModuleNotFoundError.
The base environment I use does not contain the lifelines package when I verify its contents using the Anaconda Navigator.
The jupyter notebooks are run on Anaconda Powershell, and so are the environments and packages.
Installing on the Windows Powershell will never work. Running the conda install -c conda-forge lifelines in the Anaconda shell solved the issue.
So silly, yet so time consuming it is worth sharing.
I had a issue like this, python3 -m pip install <package_name> solved it for me. Use python -m pip install <package_name> for Python2.

About installing rasterframes module in Python

I successfully installed pyrasterframes with pip in cmd, but when I try to import it in jupyter notebook I get the following error: "No module named 'pyrasterframes'". Could you help me please?
This issue solved by removing your specific environment from jupyter by the following instruction:
"jupyter kernelspec uninstall envname"
and then installing ipykernel and readding the environment to jupyter notebooks as following:
"conda install -c anaconda ipykernel"
"ipython kernel install --user --name=envname"
notice that I should open jupyter notebooks after activating my env in cmd.
I think you can use this solution to solve similar installation problems with any other modules.

how start and install with jupyterlab notebook?

I want to start working by jupyter notebook. I am using Mac. I did the following commands in terminal.
pip install jupyterlab
pip install notebook
They were installed well now in terminal I type :
jupyter notebook
And get :
-bash: jupyter: command not found
try anaconda, the best and easiest way to use jupyter notebook
Try this:
pip install --upgrade notebook
Then run
jupyter notebook
In case, you may have some python version inconsistency, always install PiPy packages with this command:
python -m pip install jupyter
Most of time, this type of installation, resolve many issues.
If your issue not solved, refer to this question, this is about your similar problem with Jupyter in Windows.

Install python packages on Jupyter Notebook

I am trying to install 2 python packages on Anaconda Jupyter Notebook. The links to the python packages are as follow:
1) https://iapws.readthedocs.io/en/latest/modules.html
2) https://pythonhosted.org/thermopy/iapws.html#module-thermopy.iapws
But I am getting the following error on both installations. Can anyone tell me what is wrong?
Through Anaconda you should write this on your Jupyter notebook :
# Install a conda package in the current Jupyter kernel
import sys
!conda install --yes --prefix {sys.prefix} packagename
With a normal install of python you should write this on your Jupyter notebook :
# Install a pip package in the current Jupyter kernel
import sys
!{sys.executable} -m pip install packagename
By replacing packagename with the name of your package like numpy.
Cheers
Your Jupyter notebook server does not have access to internet. You operating system might have a firewall or limit internet access to third party applications, especially since this is a work laptop.
Regardless, it is easy to install components using pip. If you cannot access the internet from inside the notebook, try opening a Command Prompt as admin and simply type pip install iapws.

Categories

Resources