Can't start Ipython: no module named ipython - python

I'm trying to install iPython on a Mac and am running into several problems. I believe the build script may be saving ipython to the wrong location but am unsure how to resolve this properly.
Initially I tried installing using pip, which gave the following error:
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/bg/68k19b6d6hbgwfcgvgy0dtvr0000gn/T/pip-build-qXqxr3/simplegeneric
So I tried building from the tarball instead. This succeeded without any errors but when I tried to start ipython I got the error
File "/usr/local/bin/ipython", line 4, in <module>
from IPython import start_ipython
ImportError: No module named IPython
The contents of /usr/local/bin/ipython are as follows:
#!/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
# This script was automatically generated by setup.py
if __name__ == '__main__':
from IPython import start_ipython
start_ipython()
I tried updating pip, reinstalling python via homebrew, and consistently run into the same problem. I was able to successfully install numpy, scipy, and matplotlib, all of which appear in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages while ipython does not.
Anyone know how to resolve this?

Related

Error running a Python program with sklearn.cluster - "DLL load failed while importing _pairwise_distances_reduction"

I am running Windows 10, and I have Python installed.
When trying to run a Python program with the line from sklearn.cluster import DBSCAN in it, I get the following error:
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\sklearn\metrics\pairwise.py", line 33, in <module>
from ._pairwise_distances_reduction import PairwiseDistancesArgKmin
ImportError: DLL load failed while importing _pairwise_distances_reduction: The specified module could not be found.
I have tried solving this by entering each of these in the command line (separately, not all at once) and checking whether or the program works:
pip install sklearn
pip install scikit-learn
pip uninstall scipy then pip install scipy
pip uninstall numpy then pip install numpy
I still get the same error when running the program. I'm having difficulty troubleshooting this, searching for "_pairwise_distances_reduction" returns no helpful results.
Is there something I'm supposed to install that I missed?
I was having this problem too, I installed Visual C++ Redistributable Runtimes libraries and it solved my problem.

Importing the numpy c-extensions failed in VS Code

Getting error with VS Code in installing pkg Numpy and Pandas. Any solution on how we can fix the issue? Thanks.
Error:
from . import _distributor_init
Traceback (most recent call last):
File ".\Form_validate.py", line 1, in <module>
import pandas as pd
File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\__init__.py", line 17, in <module>
"Unable to import required dependencies:\n" + "\n".join(missing_dependencies)
ImportError: Unable to import required dependencies:
numpy:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy c-extensions failed.
- Try uninstalling and reinstalling numpy.
- If you have already done that, then:
1. Check that you expected to use Python3.7 from "C:\ProgramData\Anaconda3\python.exe",
and that you have no directories in your PATH or PYTHONPATH that can
interfere with the Python and numpy version "1.18.1" you're trying to use.
2. If (1) looks fine, you can open a new issue at
https://github.com/numpy/numpy/issues. Please include details on:
- how you installed Python
- how you installed numpy
- your operating system
- whether or not you have multiple versions of Python installed
- if you built from source, your compiler versions and ideally a build log
- If you're working with a numpy git repository, try `git clean -xdf`
(removes all files not under version control) and rebuild numpy.
Note: this error has many possible causes, so please don't comment on
an existing issue about this - open a new one instead.
Original error was: DLL load failed: The specified module could not be found.
There are two solutions.
The first is to reinstall numpy, including its architecture tools. Reinstall the package by using the following code in sequence:
pip uninstall -y numpy
pip uninstall -y setuptools
pip install setuptools
pip install numpy
The second solution is to add the path to the environment variable. In fact, pylance did not find this file because
File "C:\ProgramData\Anaconda3\lib\site-packages\pandas_init_.py", line 17,
If you try to make Python output sys.path, you will find that it is anaconda3 instead of Anaconda3.
So, adding the path to environment variable can solve it.
This happens because if VS Code is launched apart, as usual, it will recognize Python from Anaconda setup but will have trouble loading imports.
Fix: Close VS Code. Then open anaconda shell, i.e., the terminal, and from there launch VS code with the comand:
Anaconda_prompt> code
You'll see terminal inside VS Code will run automatically the command:
conda activate base
Then run your program again within VS Code, and should work fine as expected.

ImportError: No module named IPython.paths when running jupyter notebook?

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

python scikit error - no module named sklearn

When i follow the website (https://www.kaggle.com/wiki/GettingStartedWithPythonForDataScience) and type python makeSubmission.py I get the following error message :
ImportError: No module named sklearn
I think I have already successfully installed the following:
Python 3.4 for windows
sciPy,NumPy and matplotlib
setuptools
scikit-learn
PyCharm
I then opened "Python 3.4 command line" and typed import sys; print(sys.__path__),but I got the message
Traceback (most recent call last): File "<stdin>", line 1, in <module>
AttributeError: module object has no attribute '__path__'
Anyone can help?
Looks like you haven't installed scikit-learn properly. pip install -U scikit-learn should do the job. Also, I would suggest downloading the Anaconda distribution of python if you're planning to use python for kaggle contests. It takes care of all the necessary dependencies and contains all the commonly needed python packages for the contest. I found that easier than the tedious download of the dependencies. Here's the Link
The Ubuntu 14.04 package is named python-sklearn (formerly python-scikits-learn) and can be installed using the following command:
sudo apt-get install python-sklearn
If you are using PyCharm or any other IDE, then you have to install 'sklearn' separately in PyCharm tool too. In My Case I am using PyCharm, select
File Menu-> Default Settings-> Project Interpreter -> Press + button and type 'sklearn'
Press install button. Installation will be done in 10 to 20 seconds.
2nd option is if you already installed 'sklearn' using terminal then you have to set path in your PyCharm IDE.

ImportError: cannot import name start_ipython

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()

Categories

Resources