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.
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
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'm trying to use scipy in a jupyter notebook and it says I have it installed, but when I try to import it, it gives me the following error.
Any help would be great. thank you.
TLDR: try this
import sys
!{sys.executable} -m pip install scipy
A bit more info:
Jupyter notebooks are able to work with multiple kernels, which are essentially pointers to the Python (or other language) executable that the notebook uses. In a Python kernel, you can figure out which one is being used by typing
import sys
print(sys.executable)
When you run a bash command in the notebook, like !pip install scipy, that uses the bash environment that was active when you launched the notebook which is not necessarily associated with the Python kernel you are using. That means that it may be installing scipy in a different Python location. You can figure out which Python your shell points to by running !which python. If this doesn't match, then !pip install will not be installing in the right place.
You can fix this by explicitly telling the bash prompt which Python/pip you want to use. For example, this should do the trick:
import sys
!{sys.executable} -m pip install scipy
This runs the pip version associated with your executable, and installs scipy with that. For some more details on what's happening behind the scenes, check out this answer.
The pip that you execute is using a shell that may (and that is probably the case here) have a different python interpreter than the one of the jupyter notebook!
Jake VanderPlas to the rescue https://twitter.com/jakevdp/status/841791667472543745
Do the following in the notebook
import sys
sys.executable
Depending on the output of "sys.executable", adjust your command-line call, still in the notebook
!/usr/bin/python3 -m pip install scipy
But as you have scipy installed, the issue is to understand why your anaconda scipy is not found. Do you have a default virtualenv for all your python use? How do you start the notebook?
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.
I installed matplotlib with package manager in Linux Mint 17.1. When I type import matplotlib in python3 terminal, everything works fine. However, when I create virtualenv, and then I run this command, Python cannot find this module. Can I somehow force my virtual environment to see it is already installed?