I cannot import pandas_datareader on my jupyter notebook(via anaconda, python3) on my windows 10 laptop. It has been installed and I can see the file but It's having errors with importing into the jupyter notebook file. Any help?
I have tried :
pip install pandas-datareader ,
pip3 install pandas-datareader ,
conda install -c anaconda pandas-datareader
I expect the the code to run smoothly however I get
ModuleNotFoundError Traceback (most recent call last)
in ()
----> 1 import pandas_datareader
ModuleNotFoundError: No module named 'pandas_datareader'
Most obvious reason can be that you are using differnt enviroments(kernels) for jupyter notebook and others. Try running this code inside jupyter notebook empty project:
try:
from pip._internal.operations import freeze
except ImportError: # if your pip version is bigger then 10
from pip.operations import freeze
requirements = freeze.freeze()
for i in requirements:
print(i)
and check if there are your's missing imports
You have to run CMD Prompt from Anaconda navigator or find it from Start menu. Then use this command:
conda install pandas_datareader
I underwent similar difficulties and successfully fixed thanks to this post - Trouble installing some libraries in python (oauth2client and gspread) Conda is installing packagies to environment for Anaconda which is obviously different than pip uses.
Related
I was trying to use numpy in Jupyter Notebook in a Python3 virtual environment, but the encountered an error.
In terminal, I did:
$ python3 -m venv py3env
$ source py3env/bin/activate
(py3env)$ jupyter notebook
And on the Jupyter page, I created a new notebook and executed the followings
!pip install numpy
import numpy as np
And the resulting output is this:
Requirement already satisfied: numpy in /Users/MyName/py3env/lib/python3.9/site-packages (1.20.2)
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-4-d83b6b4f94f9> in <module>
1 get_ipython().system('pip install numpy')
----> 2 import numpy as np
ModuleNotFoundError: No module named 'numpy'
The package is already installed but still cannot be found...?
Is there a way to fix this issue?
You may be using pip from a different python installation.
To install with the same python executable as your jupyter kernel, in one cell run:
import sys
Then in another cell run:
!{sys.executable} -m pip install numpy
It would appear you are trying to call a dependency you installed on a virtual environment, attempt to reinstall numpy on jupyter, then try again.
I'm trying to learn PyCaret but having a problem when trying to import it in Jupyter Lab.
I'm working in a virtualenv and installed pycaret via pip:
pip install pycaret
I can confirm its installed via pip list:
prompt-toolkit 3.0.7
protobuf 3.13.0
py 1.9.0
pycaret 2.1.2
pycparser 2.20
The very first line in the notebook is:
from pycaret.nlp import *
however this results in:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-3-7c206b4a9ead> in <module>
----> 1 from pycaret.nlp import *
2 import psycopg2
3 import sys, os
4 import numpy as np
5 import pandas as pd
ModuleNotFoundError: No module named 'pycaret'
I'm pulling my hair out trying to figure this out and can't find anyone else with something similar.
I've tried to import via the python shell as well and that works perfectly.
You should create a seperate environment for installing time series alpha module
after creating a new environment and switching into
pip install pycaret-ts-alpha
and then you will be able to access
https://towardsdatascience.com/announcing-pycarets-new-time-series-module-b6e724d4636c
I forgot that you had to install modules via Jupyter.
Following this guide: http://jakevdp.github.io/blog/2017/12/05/installing-python-packages-from-jupyter/index.html
Installing like so:
# Install a pip package in the current Jupyter kernel
import sys
!{sys.executable} -m pip install numpy
Got it working
First Create a new environment conda documentation
Second Download the Pycaret with this instruction
Third check your sklearn version is greater thansklearn>=0.23.2.
Because if it's greater PyCaret is not compatible with that.
Nothing works for you? Download directly from github with this command
pip install git+https://github.com/pycaret/pycaret.git#egg=pycaret
I read on the tutorial page of pycaret that to install it through a Jupyter-notebook you should add an exclamation mark in front of the python command in the Jupyter-cell:
!pip install pycaret
I'm facing weird issue in my Jupyter-notebook.
In my first cell:
import sys
!{sys.executable} -m pip install numpy
!{sys.executable} -m pip install Pillow
In the second cell:
import numpy as np
from PIL import Image
But it says : ModuleNotFoundError: No module named 'numpy'
I have used this command to install Jupyter notebook :
sudo apt install python3-notebook jupyter jupyter-core python-ipykernel
Additional information :
pip --version
pip 20.2.2 from /home/maifee/.local/lib/python3.7/site-packages/pip (python 3.7)
python --version
Python 3.7.5
Thanks to #suuuehgi.
When Jupyter Notebook isn't opened as root:
import sys
!{sys.executable} -m pip install --user numpy
I've had occasional weird install issues with Jupyter Notebooks as well when I'm running a particular virtual environment. Generally, installing with pip directly in the notebook in this form:
!pip install numpy
fixes it. Let me know how it goes.
Restarting the kernal from the Jupyter Notebook solved this issue for me
I had a similar issue. Turns out I renamed an upstream path. And I hadn't deactivated my conda env first. When I deactivated the env.
conda deactivate
Then when I activated it again, everything was as it should have been.
conda activate sample
Now I am seeing other issues with jupyter themes... but its not impacting my numpy code. So, at least I fixed the "ModuleNotFoundError: No module named 'numpy'" error
I have the same problem. My numpy is installed, I am using the same folder as usual.
If I try 'conda deactivate', I get the message:
ValueError: The python kernel does not appear to be a conda environment. Please use %pip install instead.
I added a print of the 'pip install numpy' result and the 'Module not found error' after
Here is a solution which worked for me:
lib_path="c:\\users\\user\\python_39\\lib\\site-packages\\"
MODULE_NAME = "module_to_import"
MODULE_PATH = lib_path+MODULE_NAME+"\\__init__.py"
import importlib
import sys
spec = importlib.util.spec_from_file_location(MODULE_NAME, MODULE_PATH)
module = importlib.util.module_from_spec(spec)
sys.modules[spec.name] = module
spec.loader.exec_module(module)
import module_to_import
I have technically already installed pandas-profiling using
pip install pandas-profiling
But when I try to import it, I get the following error:
import numpy as np
import pandas as pd
import pandas_profiling
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-e1a23f2a6f04> in <module>()
1 import numpy as np
2 import pandas as pd
3 import pandas_profiling
ModuleNotFoundError: No module named 'pandas_profiling'
First Error Image
So I tried installing it in Jupyter Notebook and got the following error as well:
import sys
!{sys.executable} -m pip install pandas-profiling
Collecting pandas-profiling
Could not find a version that satisfies the requirement pandas-profiling
(from versions: )
No matching distribution found for pandas-profiling
Second Error Image
I am also unable to install it using conda for both as I am unable to establish a connection to conda.anaconda.org for some reason.
To others who are looking to resolve this issue try these alternate steps :
Run pip install pandas-profiling command in a separate cell in the jupyter notebook.
After this just restart the kernal and run again. This should definitely work. Worked for me.
Based on the comments I was able to figure out the issue. I had to install jupyter notebook outside of the Anaconda root env and open it from the terminal.
pip3 install jupyter notebook
Once I did that it imported properly.
Steps:
Download the ZIP
Open Anaconda Prompt and go to the directory and extract the files to a folder
cd
C:\Users\farah\Downloads\pandas-profiling-master\pandas-profiling-master
Then type python setup.py install
Now you can use:
import pandas_profiling as pp
df = pd.read_csv('1234.csv')
pp.ProfileReport(df)
Reference: Pandas profiling
!pip install pandas_profiling # Run this from Jupytor notebook Ignore the warnings if any
from pandas_profiling import ProfileReport #restart the kernel if throws error
ProfileReport(df)
Note: This worked for me on Windows 10
From Anaconda Prompt:
conda install -c conda-forge pandas-profiling
I'm trying to install 'frida' on my Anaconda environment, and although it installs fine, I keep getting an error when importing it from IPython:
In [4]: import frida
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-4-58e5c65e5010> in <module>()
----> 1 import frida
ImportError: No module named frida
On the normal python shell the import works fine. The problem is only with IPython.
I've tried using easy_install from the conda command line - no go.
I've tried this from an IPython shell:
In [5]: easy_install.main( ["-U","frida"] )
And the package install successfully, but IPython still gave an error when importing it.
pip doesn't find the package.
I seem to be missing something with the IPython packages - How does one install packages to IPython?
If you are working in virtualenv, then installing IPython into virtualenv resolve such problems.
Usually, IPython is giving this advice when it start inside of virtualenv.