Hey guys I really need help here. When I load up my conda prompt in base env and use pip list it shows that opencv-python is installed.
however when i import cv2 on my jupyter notebook i get an error which says - ModuleNotFoundError: No module named 'cv2'
I then used os.sys.path and it turns out that all the directories point to my conda env named 'py37' and not my base env which i have used to launch the jupyter notebook. How do i make sure all the pip installed packages are available on my base env?
Related
I am trying to use the module datefinder inside Jupyter Notebook. After activating a virtual environment inside the terminal, I installed this module using the following command: conda install -c conda-forge datefinder. When I try to import this module inside Jupyter notebook using from datefinder import find_dates I see this error
ModuleNotFoundError: No module named 'datefinder'
In the terminal (using Python 3.9.6), I can import the module datefinder but not inside the Jupyter Notebook (using Python 3.7.6). After that I also used pip install datefinder inside the Jupyter Notebook to install datefinder. After successfully installing datefinder, when I again tried to import this module, I still saw the same error ModuleNotFoundError: No module named 'datefinder'. The same problem persisted, I could use the module inside terminal and not inside the notebook.
I faced similar problem when installing opencv using conda and troubleshooted this by adding kernel manually as described in this page https://www.programmersought.com/article/97466914065/ . I have also tried by changing the default kernel to the kernel I created manually and then tried to import this module and still I saw the same error.
Perform the installation on the jupyter notebook as shown below:
pip install datefinder
for more go to Github
I've found the solution:anaconda - graphviz - can't import after installation
I want to use graphviz and follow the commend in https://anaconda.org/anaconda/graphviz
run following in terminal
conda install -c anaconda graphviz
However no matter in Jupyter Notebook, python or Pycharm to import graphviz, it always shows
ModuleNotFoundError: No module named 'graphviz'
How to solve this problem? Thank you.
PS:
when run which python in terminal: it return /opt/anaconda3/bin/python, therefore I use anaconda environment by default. And I have only one environment in anaconda that is root.
when I run conda list in terminal, I can find this line :
graphviz 2.40.1 hefbbd9a_2
I found a weird thing:
my pip and conda use the same environment:
run :which pip
get : /opt/anaconda3/bin/pip
run : which conda
get : /opt/anaconda3/bin/conda
However when I run pip list, I cannot find graphviz and many other packages which shows in conda list. For these packages show in conda list but not in pip list, I also cannot import them no matter in Jupyter notebook, python, pycharm etc. Why this happens?
After using "conda install attrs", other package installations are working fine without any http connection or ModuleNotFoundError errors. Please try and let me know.
Importing pysftp into Jupyter Notebook
While importing pysftp into Jupyter Notebook, ModuleNotFoundError is shown.
Checking import of pysftp on device?
I have verified the package installation with
pip list and pip show pysftp
Had imported pysftp package(v0.2.9) and installed it in the below location
C:\users\xxxxxx\appdata\roaming\python\python37\site-packages
Check : Package installed OKAY
Check about package correct path linking from cmd prompt?
I'm using Python 3.7.0 on a WIN machine, verifyed the site package location using
import sys and sys.path
image confirms linking of PATH to correct location and the package is successfully executed when python is run through cmd prompt
Check : Path link and cmd run OKAY
Now could anyone help me solve why the package import in Jupyter Notebook is throwing an error?
Thank you
Edit 1: Check for different environment installed? added based on one of the answer
Only one environment is present in the machine
I got the same. I solved by installing directly within Jupyter using the following command:
import sys
!{sys.executable} -m pip install dice-ml
Are you running the notebook through a virtual environment?
You can try running the same commands as you did on CMD by preceding it with ! as follows:
!pip list
Ideally this should list the same contents as shown in CMD. However the results may be different if you are running Jupyter notebook in a virtual environment. If you are unable to see pysftp, you need to install it within the virtual environment. This can be done from within your notebook as:
!pip install pysftp
I have tried all the methods available to install keras but of no use. when I install it using anaconda prompt it, it installs along Thano. But eveytime I import in jupyter file, jupyter can not find it and gives this error above:
ModuleNotFoundError: No module named 'keras'
I've installed both pandas and jupyter notebook on my virtualenvs(python3).
When I check which jupyter, it's correctly refer to my envs. However, I can't import pandas when I run it in the browser.
When I run the ipython, I can import the pandas module though...
ImportError: No module named 'pandas'
Any help?
Jupyter is built with the Anaconda Python distribution (and the conda environment manager) in mind. Although some work has been done to remediate this issue, using jupyter with virtualenv is discouraged.
In this case it sounds like jupyter is using your default (root) Python environment, because it's not aware of your virtualenv one. See here for details on how to fix that.
If you land here looking for the answer, this is it (taken from the question #Aleksey Bilogur refers):
source activate ENVNAME
pip install ipykernel
python -m ipykernel install --user --name ENVNAME --display-name "Python (whatever you want to call it)"
It is really important that you install ipykernel in your virtualenv and that you launch jupyter notebook also from you ENVNAME.
Once you've done that, check if the path to your ENVNAME appears when executing from your notebook:
import sys
sys.path
If it does not, something went wrong and it won't work.