ImportError: cannot import name 'ellipkm1' - python

I've seen some answers to my issue, but none seem sufficiently applicable. Here's my issue: I'm by no means a Python expert, but am trying to experiment with a fairly complex Python package. (Don't ask...) When I try to import something I need to move forward, I get the following error (IDLE output):
import scipy.special as special
Traceback (most recent call last):
File "<pyshell#16>", line 1, in <module>
import scipy.special as special
File "C:\DevTools\Python35\lib\site-packages\scipy\special\__init__.py", line 629, in <module>
from .basic import *
File "C:\DevTools\Python35\lib\site-packages\scipy\special\basic.py", line 14, in <module>
from ._ufuncs import (ellipkm1, mathieu_a, mathieu_b, iv, jv, gamma, psi, zeta,
ImportError: cannot import name 'ellipkm1'
My environment:
Windows 10, 64-bit
Python 3.5.1 (64-bit)
Installed packages:
Bottleneck (1.0.0)
numpy (1.10.4)
pandas (0.18.0)
Pint (0.7.2)
pip (8.1.0)
python-dateutil (2.5.0)
pytz (2016.1)
PyYAML (3.11)
requests (2.9.1)
scipy (0.17.0)
setuptools (18.2)
six (1.10.0)
Some were installed via straight 'pip install [package]'; others, because I couldn't get all the necessary C compilers set up on my machine, installed from wheel files from http://www.lfd.uci.edu/~gohlke/pythonlibs/ , as follows:
PyYAML-3.11-cp35-none-win_amd64.whl
pandas-0.18.0-cp35-cp35m-win_amd64.whl
Bottleneck-1.0.0-cp35-cp35m-win_amd64.whl
scipy-0.17.0-cp35-none-win_amd64.whl
Along the way I've had to reverse-engineer failed DLL loads, missing runtime DLLs, etc, but seemingly all of these have now been resolved--yet I still get the darn error above.
Any help would be greatly appreciated. Sorry if I've missed any information that may be helpful in troubleshooting this.
Thanks in advance.

As indicated at the top of Dr. Gohlke's excellent page, he writes
Many binaries depend on NumPy-1.10+MKL ...
and the scipy section states:
Requires numpy+mkl and optionally pillow.
I suspect there's a linking issue hidden somewhere where somebody is trying to call an MKL function and it can't be found, hence the module fails to load. It certainly wouldn't hurt to install the numpy wheel to see if that's the case.
Also, your import can simply be:
from scipy import special

Related

Python 3.6.8 - Jedi - ImportError: cannot import name 'traverse_parents'

<TL;DR>
When running import jedi in python 3.6.8 I get the following import error (see end of post for full traceback):
...
from jedi.common import traverse_parents
ImportError: cannot import name 'traverse_parents'
</TL;DR>
I checked in ~/.local/lib/python3.6/site-packages/jedi/common.py : There's a function called traverse_parents alright so there's definitely some witchery at work. Not the first time I've run into one of those "undefined name" problems, but I'm running out of ideas on this one.
Already tried :
uninstalling, reinstalling, upgrading the "jedi" package for pip3
pretty much the same jazz for a couple other packages with "jedi" in their names
upgrading pip3 to 20.2.1 and redoing the same reinstalling routine
installing jedi for python2 because why not (hey, it works fine in python2 but who cares)
also tried installing python-jedi from apt-get (I removed it afterwards)
incantations to ancient Babylonian demons (to no avail, they don't work Sundays)
Vague clues on how I might fix it :
getting the latest version of jedi from github and somehow installing it without making a mess (fat chance)
uninstalling jedi and reinstalling it from within Neovim (hey that might achieve the previous point)
I've scoured the web for the answer to this problem but I'm getting nowhere. Has anyone experienced something similar and managed to solve it ?
Any suggestion welcome.
The full traceback :
Error detected while processing function provider#python3#Call:
line 18:
Error invoking 'python_execute' on channel 5 (python3-script-host):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/vee/.local/lib/python3.6/site-packages/jedi/__init__.py", line 32, in <module>
from jedi.api import Script, Interpreter, set_debug_funcion, \
File "/home/vee/.local/lib/python3.6/site-packages/jedi/api/__init__.py", line 24, in <module>
from jedi.api import classes
File "/home/vee/.local/lib/python3.6/site-packages/jedi/api/classes.py", line 26, in <module>
from jedi.inference import imports
File "/home/vee/.local/lib/python3.6/site-packages/jedi/inference/__init__.py", line 70, in <module>
from jedi.inference import imports
File "/home/vee/.local/lib/python3.6/site-packages/jedi/inference/imports.py", line 24, in <module>
from jedi.inference import sys_path
File "/home/vee/.local/lib/python3.6/site-packages/jedi/inference/sys_path.py", line 8, in <module>
from jedi.common import traverse_parents
ImportError: cannot import name 'traverse_parents'
Fixed it :
I reinstalled the latest version of jedi via pip with this command :
pip3 install -e git://github.com/davidhalter/jedi.git#egg=jedi
Now, the command import jedi doesn't generate any exception and it seems to work alright in Neovim.
The reason why the default version installed with pip3 install jedi generated that ImportError is beyond what I can guess. Maybe this version was faulty itself, maybe some quirk of my python environment...
Edit: According to David Halter in the comment below, it seems to be a pip bug
Anyway. If you have the same problem, try this fix.

ImportError: cannot import name get_ast_names error on lmfit

I have recently updated to Ubuntu 18.04.1 LTS. After that I tried to run some of my python codes and I got an error related to the lmfit package, here's the code:
import scipy
from asteval import get_ast_names
import lmfit
(I have explicitly added the scipy and asteval modules to check python was finding them porperly)
I obtained this error:
Traceback (most recent call last):
File "/home/maurizio/Documents/Python/Programmini/PhD/TEAS/Test.py", line 3, in <module>
import lmfit
File "/home/maurizio/.local/lib/python2.7/site-packages/lmfit/__init__.py", line 42, in <module>
from .confidence import conf_interval, conf_interval2d
File "/home/maurizio/.local/lib/python2.7/site-packages/lmfit/confidence.py", line 12, in <module>
from .minimizer import MinimizerException
File "/home/maurizio/.local/lib/python2.7/site-packages/lmfit/minimizer.py", line 35, in <module>
from .parameter import Parameter, Parameters
File "/home/maurizio/.local/lib/python2.7/site-packages/lmfit/parameter.py", line 8, in <module>
from asteval import Interpreter, get_ast_names, valid_symbol_name
ImportError: cannot import name get_ast_names
which basically states that lmfit cannot find the function get_ast_names from asteval, although the python interpreter doesn't complain when I try to import it so it should be properly installed.
I have found this question with a similar problem and the guy in the comments claims he solved it by reinstalling it with pip3, so I tried to compile it with python3 and there's no problem so the issue concerns only python 2
Any help?
I believe you must have conflicting versions of lmfit and asteval. This should have been automatically noticed (and ideally resolved) when installing lmfit, but something there appears to have gone wrong. For the latest releases, you should get
>>> import asteval
>>> asteval.__version__
0.9.12
>>> import lmfit
>>> lmfit.__version__
0.9.11
Depending on how you installed these, you may need to check for and remove older versions of asteval in your $HOME/.local/lib/python2.7/site-packages/ folder and re-do pip install asteval.

ImportError: cannot import name '_ccallback_c'

Initially I was getting this error (No Module name was found scipy) So I installed a Scipy wheel file. Now I don't get the same error any more but I get cannot import name "_ccallback_c".
The error seems to be triggered at the fourth line of code. I have done my research and saw that other people suggested to try an environment such as Anaconda. I have seen it work on idle, and that solution isn't ideal for me.
Traceback:
Traceback (most recent call last):
File "C:\Users\joesh\Desktop\Python\Machine Learning\1st tutorial.py", line 4, in <module>
from sklearn import preprocessing, cross_validation, svm
File "C:\Users\joesh\Desktop\Python\lib\site-packages\sklearn\__init__.py", line 134, in <module>
from .base import clone
File "C:\Users\joesh\Desktop\Python\lib\site-packages\sklearn\base.py", line 10, in <module>
from scipy import sparse
File "C:\Users\joesh\Desktop\Python\lib\site-packages\scipy\__init__.py", line 118, in <module>
from scipy._lib._ccallback import LowLevelCallable
File "C:\Users\joesh\Desktop\Python\lib\site-packages\scipy\_lib\_ccallback.py", line 1, in <module>
from . import _ccallback_c
ImportError: cannot import name '_ccallback_c'
And the code:
import pandas as pd
import quandl, math
import numpy as np
from sklearn import preprocessing, cross_validation, svm
from sklearn.linear_model import LinearRegression
I had the same error on USING Anaconda, so I am not sure if using it would make any difference.
I solved it by just uninstalling scipy and re-installing it using pip:
pip uninstall scipy
you'll get this message:
Uninstalling scipy-1.1.0: Would remove:
c:\users\thesh\appdata\local\programs\python\python36-32\lib\site-packages\scipy-1.1.0.dist-info*
c:\users\thesh\appdata\local\programs\python\python36-32\lib\site-packages\scipy*
Proceed (y/n)?
press y, and after pip is done, type:
pip install scipy
Having just moved to MSVS 2017 for Python (ML) development, I encountered this and other errors related to missing modules. The problem (and all related problems like it) has a frustratingly simple solution: when I originally started coding in Python, I installed everything from the command line - apparently, MSVS 2017 doesn't "see" those installations (and, in fact, they sometimes conflict, since the underlying python may be tapping older libs); so, the solution is to:
Use the command line version of 'pip uninstall ...' where '...' is the library having missing dependencies (scipy, in this case). Then, in the MSVS 2017 command line on the Python environment window (usually, top right in the default display configuration), reload the library (in this case, typing 'scipy' will format a command line for execution [in the list control below the command textbox]) that will read something like 'pip install scipy' (or whatever library needs to be reinstalled for MSVS).
You may have to do this for many (or all) of your previous Python package installations where these missing module errors persist.
Can be resolved, by uninstalling and reinstalling using pip on Anaconda Prompt:
pip uninstall scipy
After the uninstall, you can reinstall with:
pip install scipy
When you installed scipy with pip in a Python version 3.6 and later try to run your code with Python 3.7 you will encounter this problem. So one solution is to uninstall scipy
pip3 uninstall scipy
and reinstall it (using an environment with Python 3.7):
pip3 install scipy
This will make sure that the installed version of scipy is compatible with your version of Python.
PS: When you updated Python from Python 3.6 to Python 3.7 it might be necessary to also reinstall pip, so that pip will use the correct version of Python internally.
I ran into this when I was following these instructions on how to use a virtual environment to use the pre-built version of SciPy. The simplest solution for me was to simply comment out from . import _ccallback_c under scipy\_lib\_ccallback.py.
I first had the error with scipy. So I ran the command python -m pip install -user numpy scipy matplotlib ipython jupyter pandas sympy noseand it worked perfectly. I was installing everything with pip, so I decided to use Anaconda. I installed and checked to add to the PATH. From there, the same code that was executed before normally stopped working and displays the error similar to that of the question. I uninstalled Anaconda and it is now working again.
Erro:
$ winpty python ia.py
Traceback (most recent call last):
File "ia.py", line 11, in <module>
from sklearn import tree #importando a biblioteca e a árvore p/ o classifica
dor
File "C:\Users\ferna\Anaconda3\lib\site-packages\sklearn\__init__.py", line 13
4, in <module>
from .base import clone
File "C:\Users\ferna\Anaconda3\lib\site-packages\sklearn\base.py", line 11, in
<module>
from scipy import sparse
File "C:\Users\ferna\AppData\Roaming\Python\Python36\site-packages\scipy\__ini
t__.py", line 118, in <module>
from scipy._lib._ccallback import LowLevelCallable
File "C:\Users\ferna\AppData\Roaming\Python\Python36\site-packages\scipy\_lib\
_ccallback.py", line 1, in <module>
from . import _ccallback_c
ImportError: cannot import name '_ccallback_c'
Código:
from sklearn import tree #importando a biblioteca e a árvore p/ o classificador
#COLLLECT TRAINING DATA
features = [[140,1],[130,1],[150,0],[170,0]]
labels = [0,0,1,1]
# TRAIN CLASSIFIER
clf = tree.DecisionTreeClassifier() #Classificador
clf = clf.fit(features, labels) #algoritmo de decisão p/ encontrar padrões
#MAKE PREDICTIONS
print(clf.predict([[160, 0]])) #entrada de dados para o tratamento
Try this:
python -m pip install --upgrade scipy
After digging in, to give the full background on this, first of all SciPy relies on having NumPy already installed. The SciPy wheel's setup.py file uses NumPy functionality to configure and install the wheel.
SciPy setup.py:
...
if __name__ == '__main__':
from numpy.distutils.core import setup
setup(**configuration(top_path='').todict())
Secondly, when just trying to use the wheel, if you run into this error, you can see after inspecting the wheel's files that the reason is the binary wheels have a naming convention where the shared object file, here it's called _ccallback_c.so, is instead named based on the architecture that the binary wheel supports. When trying to import the shared object by file name in /_lib/_ccallback.py it can't find it, hence this error (line 1 in /_lib/_ccallback.py) because, instead of being named _ccallback_c.so it's called _ccallback_c.cpython-36m-x86_64-linux-gnu.so or another architecture variation:
from . import _ccallback_c
These file names seem to be an artifact of libraries that are using Cython and Cython's adherence to PEP 3149 (ABI version tagged .so files). But the easiest fix is to change the .whl extension to .zip and rename all those relevant .so files to not contain the architecture snippet. Then change .zip -> .whl and it should be good to go unless it's the wrong architecture for the platform you're using, in which case you need to download the appropriate platform wheel for your platform.

Trying to install mathplot.lib for python 2.7.11. But Cannot find a suitable process. Have tried various ways from Youtube Tutorials, but invain

I have installed matplotlib-1.5.0.win-amd64-py2.7 from sourcefourge.net after downloading and installing numpy using commandprompt by using pip: pip install numpy. But when I write the following code it Gives me error. Help me out.
Code:
from matplotlib.pylab import *
pylab.plot([1,2,3,4],[1,2,3,4])
pylab.show()
It gives me following error message:
Traceback (most recent call last):
File "C:\Python27\Lib\idlelib\1.py", line 1, in <module>
from matplotlib.pylab import *
File "C:\Python27\lib\site-packages\matplotlib\__init__.py", line 124, in <module>
from matplotlib.rcsetup import (defaultParams,
File "C:\Python27\lib\site-packages\matplotlib\rcsetup.py", line 25, in <module>
from matplotlib.fontconfig_pattern import parse_fontconfig_pattern
File "C:\Python27\lib\site-packages\matplotlib\fontconfig_pattern.py", line 25, in <module>
from pyparsing import Literal, ZeroOrMore, \
ImportError: No module named pyparsing
There is an easy and complete guide on the Matplotlib Website.
Try and follow this one.
refer to this answer of mine
https://stackoverflow.com/a/38618044/5334188
install numpy
pip install numpy
If you face installation issues for numpy, get the pre-built windows installers from http://www.lfd.uci.edu/~gohlke/pythonlibs/ for your python version (python version is different from windows version).
numpy 32-bit: numpy-1.11.1+mkl-cp27-cp27m-win32.whl
numpy 64-bit: numpy-1.11.1+mkl-cp27-cp27m-win_amd64.whl
Later you require VC++ 9.0, then please get it from below link Microsoft Visual C++ 9.0 is required. Get it from http://aka.ms/vcpython27
Then install matplotlib using
pip install matplotlib
If you face errors, please download below from http://www.lfd.uci.edu/~gohlke/pythonlibs/, which will do the rest.
32-bit: matplotlib-1.5.3-cp27-cp27m-win32.whl
64-bit: matplotlib-1.5.3-cp27-cp27m-win_amd64.whl
works like charm

Installing Pylab/Matplotlib

I'm trying to write a program that plots a graph, which made me look into
Matplotlib.
I found a tutorial that started out with this little program, that worked fine:
from pylab import *
def main():
X = np.linspace(-np.pi, np.pi, 256, endpoint=True)
C,S = np.cos(X), np.sin(X)
plot(X,C)
plot(X,S)
show()
if __name__ == '__main__':
main()
Then I tried to run it on another computer, where it did not work at all. I tried to download Pylab and Matplotlib. When I had installed Matplotlib it demanded something called dateutil, when I got dateutil it demanded something called six. I downloaded six, but it didn't work properly.
It doesn't feel like I'm on the right track. What should I do to get a proper installation?
EDIT:
I'm using Python 2.7 on Windows 7.
The error I get is
Traceback (most recent call last):
File "C:\Users\Python\mscript\listdb2.py", line 19, in <module>
from pylab import *
File "C:\Python27\lib\site-packages\pylab.py", line 1, in <module>
from matplotlib.pylab import *
File "C:\Python27\lib\site-packages\matplotlib\pylab.py", line 226, in <module>
import matplotlib.finance
File "C:\Python27\lib\site-packages\matplotlib\finance.py", line 21, in <module>
from matplotlib.dates import date2num
File "C:\Python27\lib\site-packages\matplotlib\dates.py", line 119, in <module>
from dateutil.rrule import (rrule, MO, TU, WE, TH, FR, SA, SU, YEARLY,
File "C:\Python27\lib\site-packages\dateutil\rrule.py", line 18, in <module>
from six import advance_iterator, integer_types
ImportError: No module named six
The file six.py is located in C:\python27\Lib\site-packages\six\six.py
The six directory also contains a file called test_six.py. If I try to run this program I also get an error:
Traceback (most recent call last):
File "test_six.py", line 5, in <module>
import.py
ImportError: No module named py
If Anaconda installed and it is already in your environment path, you can get it simply using
conda install matplotlib
in command line and then call in Python with
from pylab import *
This work for me fine as "pip install" and "easy_install" both on Win and Linux caused a lot of issues
Installing packages on *nix is easy using pip. Pip allows you to easily install packages from the Python Package Index (PyPI) with a simple pip install matplotlib. This should install all dependencies, but if it does not then you can install them manually (for instance pip install python-dateutil).
Using pip with Windows is possible though slightly more difficult for packages that require compilers and such. However, installing Python programs on Windows is simple if you use these Windows binaries provided by Christoph Gohlke.
The particular ones for matplotlib can be found here. Note that you can also find similar binaries for python-dateutil, six, etc if necessary.
*As an aside: I would strongly suggest you look into using the full matplotlib.pyplot API rather than pylab. It's much more powerful and useful, but this is just some aside advice :) *

Categories

Resources