ImportError: cannot import name flib - python

I want to use Python for trying out hddm.
I installed anaconda, Python 2.7. When I try to follow the hddm tutorial in the command line window in spyder, the following happens, which seems to be a problem in pymc:
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
import hddm
Traceback (most recent call last):
File "<ipython-input-24-17365318b31c>", line 1, in <module>
import hddm
File "/Users/c/anaconda/lib/python2.7/site-packages/hddm/__init__.py", line 7, in <module>
import likelihoods
File "/Users/c/anaconda/lib/python2.7/site-packages/hddm/likelihoods.py", line 2, in <module>
import pymc as pm
File "/Users/c/anaconda/lib/python2.7/site-packages/pymc/__init__.py", line 31, in <module>
from .distributions import *
File "/Users/c/anaconda/lib/python2.7/site-packages/pymc/distributions.py", line 30, in <module>
from . import flib, utils
ImportError: cannot import name flib
I work on Mac OS X 10.7. On the web, I find some comments concerning pymc possibly not being compiled with the correct version of gfortran, but the solutions all seem to be for windows. Also, I thought that this kind of problem should not happen with an integrated system like Anaconda?

There are two options:
use conda install -c conda.binstar.org/pymc pymc
install gfortran and use pip install -U pymc

Related

dynamic module does not define module export function (PyInit_bz2)

I am using Python3.6 on CentOS linux and have created virtual environment using venv. I installed matplotlib using pip install matplotlib and it completed successfully. Now when I am trying to import matplotlib in python command line it is producing Import Error:
>>> import matplotlib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/yogeshs/Python3.6VE/lib/python3.6/site-packages/matplotlib/__init__.py", line 127, in <module>
from . import cbook
File "/home/yogeshs/Python3.6VE/lib/python3.6/site-packages/matplotlib/cbook/__init__.py", line 13, in <module>
import bz2
ImportError: dynamic module does not define module export function (PyInit_bz2)
>>>
I read almost all the answers on similar issues on Stackoverflow and tried to follow the steps but I am unable to to resolve this problem. Can somebody please guide me through this? Thank you in advance.

ImportError: cannot import name 'PandasError'

I am very new to Python 3x, running on a mac.
Currently using a sentdex tutorial for python with finance, tried running the following script:
import datetime as dt
import matplotlib.pyplot as plt
from matplotlib import style
import pandas as pd
import pandas_datareader.data as web
style.use('ggplot')
start = dt.datetime(2000,1,1)
end = dt.datetime(2016,12,31)
df = web.DataReader('TSLA', 'yahoo', start, end)
print(df.head())
However this returns the following error message:
Traceback (most recent call last):
File "F:\Downloads\Python Work\try figuring thigns out\finance\try.py", line 1, in <module>
import pandas_datareader.data as web
File "C:\Python36\lib\site-packages\pandas_datareader\__init__.py", line 3, in <module>
from .data import (get_components_yahoo, get_data_famafrench, get_data_google, get_data_yahoo, get_data_enigma, # noqa
File "C:\Python36\lib\site-packages\pandas_datareader\data.py", line 7, in <module>
from pandas_datareader.google.daily import GoogleDailyReader
File "C:\Python36\lib\site-packages\pandas_datareader\google\daily.py", line 1, in <module>
from pandas_datareader.base import _DailyBaseReader
File "C:\Python36\lib\site-packages\pandas_datareader\base.py", line 13, in <module>
from pandas_datareader._utils import (RemoteDataError, SymbolWarning,
File "C:\Python36\lib\site-packages\pandas_datareader\_utils.py", line 5, in <module>
from pandas.core.common import PandasError
ImportError: cannot import name 'PandasError'
I think maybe there's something wrong with panda-datareader itself, which I've ensured has been upgraded to most recent version (pandas-datareader 0.3.0.post0)
Is there an older version I can install instead? I've been using pip3 to install via mac terminal.
Thanks very much for any help!
I think you installed pandas v. 0.20.1 released yesterday.
pandas-datareader is still not compatible with this version, for the moment you should stay on pandas 0.19.2:
pip install -U pandas==0.19.2
The latest version of pandas_datareader (0.5.0) takes care of this import error. You can install it with pip:
sudo pip install -U pandas_datareader
I may already be too late to the discussion but I encountered this earlier today using a brand new Azure Compute that I spun up, I did all the steps above and was always encountering the error.
It may not be explicitly stated above but restarting the kernel AFTER the steps above fixed the issue.

Numpy - ImportError: cannot import name shares_memory

I'm going to preface this by saying that I'm relatively new to Python and so please forgive me if I have difficulty understanding something.
I've recently been trying to install OpenCV on my computer following the "Installing OpenCV from prebuilt binaries" instructions found here:
http://docs.opencv.org/3.1.0/d5/de5/tutorial_py_setup_in_windows.html#gsc.tab=0
I initially tried to install OpenCV by itself, as I already had Python 3.5 and a working version of numpy. However, my attempts to import cv2 failed, and I eventually decided to uninstall Python and follow all the steps listed on the website. However, I now have this error when I try import numpy:
Traceback (most recent call last):
File "C:/PythonProgramming/SLIC/src/SLICAlgorithm.py", line 1, in <module>
import numpy
File "C:\Python27\lib\site-packages\numpy\__init__.py", line 180, in <module>
from . import add_newdocs
File "C:\Python27\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "C:\Python27\lib\site-packages\numpy\lib\__init__.py", line 4, in <module>
from type_check import *
File "C:\Python27\lib\site-packages\numpy\lib\type_check.py", line 8, in <module>
import numpy.core.numeric as _nx
File "C:\Python27\lib\site-packages\numpy\core\__init__.py", line 20, in <module>
import function_base
File "C:\Python27\lib\site-packages\numpy\core\function_base.py", line 6, in <module>
from .numeric import result_type, NaN, shares_memory, MAY_SHARE_BOUNDS, TooHardError
ImportError: cannot import name shares_memory
Process finished with exit code 1
Other people online seem to have no problem with these instructions, or at least not with numpy. What does this error mean, and what can I do to fix it? I have a 64-bit version of Windows 10 and am working in PyCharm. All help you can provide would be much appreciated.
same problem, the following fix worked for me
pip install -I numpy --force-reinstall

Python 2.5.... MatPlotLib doesn't install PyLab

I have NumPy and SciPy installed and working. I'm using Python 2.5 (MIT Intro to Programming course) so I've been installing the packages with .exe files instead of Pip or Anaconda. With MatPlotLib, I get the following errors during installation:
could not create: matplotlib-py2.5
could not create: python 2.5 matplotlib-1.0.0
could not set key value: "C:\Python25\Removematplotlib.exe" -u "C:\Python25\matplotlib-wininst.log"
I have a MatPlotLib folder in Python's Lib/site-packages directory. Importing matplotlib into IDLE works fine. But when I try to import pylab:
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
import pylab
File "C:\Python25\Lib\site-packages\pylab.py", line 1, in <module>
from matplotlib.pylab import *
File "C:\Python25\Lib\site-packages\matplotlib\pylab.py", line 216, in <module>
from matplotlib import mpl # pulls in most modules
File "C:\Python25\Lib\site-packages\matplotlib\mpl.py", line 1, in <module>
from matplotlib import artist
File "C:\Python25\Lib\site-packages\matplotlib\artist.py", line 6, in <module>
from transforms import Bbox, IdentityTransform, TransformedBbox, TransformedPath
File "C:\Python25\Lib\site-packages\matplotlib\transforms.py", line 34, in <module>
from matplotlib._path import affine_transform
ImportError: DLL load failed: The specified module could not be found.
I've looked around on different message boards but can't find anyone else with this issue.
Any ideas?

Python matplotlib not importing due to failure to import unichr

I'm running Ubuntu 13.10 with Python 2.7.5+, and whenever I try to import the matplotlib package, I get an error. Specifically, my test script has only the following code:
#!/usr/bin/python
import matplotlib.pyplot as plt
When I run the test script, here is the error:
Traceback (most recent call last):
File "./test.py", line 2, in <module>
import matplotlib.pyplot as plt
File "/usr/local/lib/python2.7/dist-packages/matplotlib/pyplot.py", line 27, in <module>
import matplotlib.colorbar
File "/usr/local/lib/python2.7/dist-packages/matplotlib/colorbar.py", line 34, in <module>
import matplotlib.collections as collections
File "/usr/local/lib/python2.7/dist-packages/matplotlib/collections.py", line 27, in <module>
import matplotlib.backend_bases as backend_bases
File "/usr/local/lib/python2.7/dist-packages/matplotlib/backend_bases.py", line 56, in <module>
import matplotlib.textpath as textpath
File "/usr/local/lib/python2.7/dist-packages/matplotlib/textpath.py", line 22, in <module>
from matplotlib.mathtext import MathTextParser
File "/usr/local/lib/python2.7/dist-packages/matplotlib/mathtext.py", line 26, in <module>
from six import unichr
ImportError: cannot import name unichr
Any idea what I'm doing wrong?
You apparently have an outdated version of six.
The unichr wrapper was added in version 1.4.0, as seen in CHANGES. I'm not sure exactly when 1.4.0 was released, but the fix for issue #25 was committed on 2013-05-18, so… some time after that.
So, if you print(six.__version__), and it's anything less than '1.4.0', that's your problem.
Depending on whether you're installing packages with pip or with your system's package manager, the solution is going to be something like one of these:
$ pip install --upgrade six
$ apt-get install six
$ brew install --upgrade six
… etc.
But meanwhile, matplotlib shouldn't be requiring 1.3 but using features only available in 1.4. Your GitHub issue matplotlib#3538 should get this fixed.

Categories

Resources