I installed jupyter via: /usr/local/opt/python/bin/python2.7 -m pip install jupyter
this install ipython version 4.1.2. However, when I run jupyter notebook, I get:
Traceback (most recent call last):
File "/usr/local/bin/jupyter-notebook", line 7, in <module>
from notebook.notebookapp import main
File "/Library/Python/2.7/site-packages/notebook/notebookapp.py", line 83, in <module>
from IPython.paths import get_ipython_dir
ImportError: No module named IPython.paths
yet, when I run from IPython.paths import get_ipython_dir in the ipython shell directly it works fine. Also when I run /usr/local/opt/python/bin/python2.7 and then the same thing, it runs successfully. Additionally, when I check the sys.executable path in python I get /usr/local/opt/python/bin/python2.7
This doesn't make sense to me. How can Ipython and my normal python (both using /usr/local/opt/python/bin/python2.7) both run this successfully, but my jupyter, installed with that specific python, cannot run the command. Any suggestions?
I had the same problem. Just now this helped me. Someone might find this useful.
from IPython.paths import get_ipython_dir
ImportError: No module named IPython.paths
So I was running Python 3 on Linux mint 17. I first uninstalled jupyter from my system using the command.
sudo -H pip3 uninstall jupyter
After successfully uninstalling I installed jupyter again with the following command.
sudo -H pip3 install jupyter
And when I launched jupyter again using
jupyter notebook
The kernel didn't die or didn't restart. Everything works fine now. I hope atleast one person finds this useful.
Upgrade ipython:
pip install ipython==5.3.0
If you cannot uninstall ipython, try this:
sudo -H pip install --ignore-installed -U ipython==5.3.0
Related
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.
I am trying to run the PyCharm profiler but I get the following error message:
Traceback (most recent call last):
File "/home/b3053674/ProgramFiles/pycharm-2017.1.4/helpers/profiler/run_profiler.py", line 164, in <module>
profiler.run(file)
File "/home/b3053674/ProgramFiles/pycharm-2017.1.4/helpers/profiler/run_profiler.py", line 89, in run
execfile(file, globals, globals) # execute the script
File "/home/b3053674/Documents/pycotools/pycotools/tasks.py", line 38, in <module>
import viz,errors, misc, _base, model
File "/home/b3053674/Documents/pycotools/pycotools/viz.py", line 53, in <module>
import matplotlib.pyplot as plt
File "/home/b3053674/anaconda2/envs/pycotools/lib/python2.7/site-packages/matplotlib/__init__.py", line 124, in <module>
from . import cbook
ImportError: cannot import name cbook
Snapshot saved to /home/b3053674/.PyCharm2017.1/system/snapshots/pycotools30.pstat
Process finished with exit code 1
I am using a conda environment which I have switched to in the terminal:
$ source activate <env>
then updated matplotlib
$pip install matplotlib --upgrade
and six just for good measure
$pip install six --upgrade
(note that I've also manually deleted these packages from site-directory of my environment and reinstalled just incase --upgrade wasn't behaving)
I've looked here and here and neither solutions solved my problem.
I've also switched the PyCharm Run configurations to use each of my conda environments in turn all of which produce the same error.
Note that the profiler has worked before in the past and the code works fine when I use the normal way of executing the code. Does anybody have any idea of what is going on?
Thanks
I encountered the same error today, although probably for a different reason - the packages for matplotlib and/or six appear to be broken.
Resolved it by downgrading to the previous versions:
conda install six=1.10.0
conda install matplotlib=2.0.2
I had the same issue.
Downgrading to matplotlib 2.0.2 seems to fix it.
pip uninstall matplotlib
pip install matplotlib==2.0.2
I had this error in jupyter but not IPython. Fixed with $ conda install matplotlib=2.0.2 as above but six not downgraded. Don't forget (as I did) to restart the kernel.
I've used the following tutorial to install Python, numpy, scipy and matplotlib:
https://penandpants.com/2012/03/01/install-python-2/
I downloaded each and installed by double-clicking. I'm using a Mac with OS X Yosemite Version 10.10.5
When I try to import numpy, scipy and matplotlib in IDLE I get the follow error message:
`>>> import numpy
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
import numpy
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/__init__.py", line 137, in <module>
import add_newdocs
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/add_newdocs.py", line 9, in <module>
from numpy.lib import add_newdoc
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/lib/__init__.py", line 4, in <module>
from type_check import *
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/lib/type_check.py", line 8, in <module>
import numpy.core.numeric as _nx
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/__init__.py", line 5, in <module>
import multiarray
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/multiarray.so, 2): no suitable image found. Did find:
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/multiarray.so: no matching architecture in universal wrapper`
Can anyone please explain to me how to resolve this?
Thanks
use terminal and type
sudo pip install numpy
sudo pip install matplotlib
sudo pip install scipy
for python3+ use pip3
I can't say for sure what's wrong with your installation, but I suspect it's due to a some PATH-conusion... Python 2.7 and Numpy should be installed on your Mac by default.
If you run the command which python, you'll see which executable the python-commands invokes... is it the same as the one you installed?
If you write python in the terminal, and press tab twice, do you see multiple options of installed python versions?
Alternative method of installation
I prefer the Anaconda Python Distribution, which you can download like the full version or minimal version, which is the one I prefer.
If you install this, you should consider uninstalling the one you just installed.
Here's how to install the mini version:
Download the installer, and run it by opening a terminal in the folder with the installer, and running the command bash Miniconda2-latest-MacOSX-x86_64.sh. This will start the text-based installer, and if you read the instructions on screen, you'll be fine.
Notice that you have to scroll to the end of the licence agreement, before you can write yes when asked to accept the terms stated.
Say yes when it asked you if you'd like it to add Anaconda Python to your path.
Anaconda Python is different from other python distributions in the regard that it comes with it's own package and environment manager conda. With conda you can have multiple versions of Python installed at the same time (or several environments of the same Python version, but with different packages or versions of packages).
To create a new environment with the name py27, which is using Python 2.7, write conda create -n py27 python=2.7 --yes. Once created, activate the environment by source activate py27.
With the new environment now active, install the packages you need by using conda: conda install scipy matplotlib --yes.
I'd also recommend installing Ipython, which is an improved shell, and possibly the Jupyter notebook: conda install ipython --yes and conda install notebook --yes.
Hope it helps.
I'm trying to install IPython notebook on OS X 10.10.2.
After all dependencies have been added, this error occurs:
File "/Library/Python/2.7/site-packages/jinja2/tests.py", line 14, in <module>
from jinja2._compat import text_type, string_types, integer_types
ImportError: cannot import name integer_types
How can I fix this?
How are you installing ipython?
If you have pip, are you using pip install ipython[all]?
I also recommend using virtualenv to start with a completely clean python2.7 install from scratch and see if you encounter the errors still. There may be some version compatibility conflicts on the system.
Alternative is you can install the Anaconda distribution which comes prepackaged with ipython and dependencies http://continuum.io/downloads
I have extracted ipython-1.1.0.tar.gz in /usr/lib/ipython-1.1.0 and have run the following commands to finish the build and installation:
root#my-laptop:/usr/lib/ipython-1.1.0# python setup.py build
root#my-laptop:/usr/lib/ipython-1.1.0# python setup.py install
I am using Python 2.6 and is installed under /usr/bin/python2.6 and have my additional packages under /usr/lib/python2.6/site-packages/
Now, when I am trying to start ipython notebook from shell command, I am getting the following ImportError message:
root#my-laptop:/usr/lib/ipython-1.1.0# ipython notebook
Traceback (most recent call last):
File "/usr/local/bin/ipython", line 5, in <module>
from IPython import start_ipython
ImportError: cannot import name start_ipython
When I tried to start the IPython instance as mentioned in README.rst file, I got the following message:
root#my-laptop:/usr/lib/ipython-1.1.0# python -m IPython
/usr/bin/python: IPython is a package and cannot be directly executed
I tried easy_install and pip install
root#my-laptop:/usr/lib/ipython-1.1.0# easy_install ipython
Searching for ipython
Best match: ipython 1.1.0
Adding ipython 1.1.0 to easy-install.pth file
Using /usr/local/lib/python2.6/dist-packages
Processing dependencies for ipython
root#my-laptop:/usr/lib/ipython-1.1.0# pip install ipython
Requirement already satisfied: ipython in /usr/lib/pymodules/python2.6
Installing collected packages: ipython
Successfully installed ipython
But the ImportError problem still remains unresolved. This is not allowing to open the interactive Python.
I found some solution in the below link, but not sure about it:
https://trac.macports.org/ticket/40119
I just ran into this problem as well. Are we sure the IPython API didn't change? I got something that looks right working with:
import IPython
IPython.Shell.start()
edit:
ok, nvmind. There was also another program I installed at the same time that decided to change PYTHONPATH.
This worked for me:
import IPython
IPython.start_ipython()