Imported package not available in Jupyter-Python - python-3.x

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

Related

Python 3.9 quandl NoModuleFound (Jupyter Notebook)

I am using Python3.9 on Windows machine. I created a virtual environment (my_venv) and activated it. cd to the my_venv folder and then did pip3 install quandl if I then run pip3 list I can see Quandl3.7.0 in the list.
making sure I am in the my_venv directory I then run Jupyter Notebook and it launches and says the kernel is called python3 (which is the only kernel available). When I then run import quandl I get "No Module named 'quandl'"
Note: I have tried the import with and without a capital Q and in both cases it gives the same error.

Azure AutoML Python SDK, Issues importing into VS Code Jupyter Notebook

I have a .yml that installs all the necessary Azure ML packages.
Upon creating the environment with the YML, I test to make sure I can import the packages, and I can.
But when I open the Jupyter notebook I will be using and import the necessary packages, one is not found.
from azureml.train.automl import AutoMLConfig
ModuleNotFoundError: No module named 'azureml.train.automl.automlconfig'
But When I import it in the command prompt, it successfully imports
It seems like this is an issue with VS code, has anyone else encountered this?
I tried reproducing the issue while importing AutoMLConfig in VSCode as below:
Followed the below steps to fix it by installing its related Python packages.
Activate the virtual environment from below command
python -m venv .venv
.venv\Scripts\activate
Then install pip install azureml and “pip install azureml-core”
Pip install azureml-train
Pip install azureml-train-automl
Also, we have a Microsoft documentation where we have all the sub packages of azureml.

Module seems to be installed yet Jupyter Notebook won't recognize module

I attempted to exectue the following code:
df = pd.DataFrame()
for file in files:
if file.endswith('.xls'):
df = df.append(pd.read_excel(file), ignore_index=True)
df.head()
but received this error on the 4th command line:.
However, when I check modules installed I receive:
Why does Jupyter not recognize xlrd as being installed? Thanks for any feedback or help.
Problem
You are using pip python's default package manager to check a package in python's default install location.
But using Anaconda's virtual environment (which probably jupyter notebook is used with) to run python script which requires packages to be installed in it's own directory via conda package maanger.
Solution
Run this command in Anaconda command pompt:
conda install -c conda-forge xlrd

I have installed cvlib in python but still can't import it

I installed miniconda and just created a conda environment:
conda create -n my_env python=3.5 anaconda
I am trying to:
import cvlib
But I am getting the error:
ImportError: No module named cvlib
So I have tried to install using:
pip3 install cvlib
This seemed to work successfully, but then when I try to import cvlib I am still getting the ImportError: No module named cvlib error (I have retarted my terminal after the installation).
Is this a problem with my PYTHONPATH not containing the path to the directory that now contains cvlib? If so, how do I find where cvlib is saved so that I can add the path?
Check if the library is in your python directory. Otherwise, make a repl.it account, and install cvlib, and check the functions or the lib name. Maybe try searching a more advanced installation of cvlib.
it might have occurred due to the version of python you installed or due to the directory, you installed.
try uninstalling the current version of python and try installing an older version of python and install it in the directory as shown below:
C:\Users\Rajish\AppData\Local\Programs\Python\Python39
also, select add the path to environment variables while installing
and after that install cvlib and all other required modules and packages
it worked for me.

conda installed some package but still ModuleNotFoundError when import this package

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.

Resources