I am working on learning how to use pandas but get the following error:
Traceback (most recent call last):
File "data_frame.py", line 2, in <module>
import pandas as pd
File "/Users/gregwinter/anaconda2/lib/python2.7/site-packages/pandas/__init__.py", line 13, in <module>
__import__(dependency)
File "/Users/gregwinter/numpy.py", line 22, in <module>
from pandas.compat.numpy_compat import *
File "/Users/gregwinter/anaconda2/lib/python2.7/site-packages/pandas/compat/numpy_compat.py", line 15, in <module>
_np_version = np.version.short_version
AttributeError: 'module' object has no attribute 'version'
I have no idea how to fix this. Anything you can tell be on how to fix this would be great.
You named a file of your own numpy.py:
/Users/gregwinter/numpy.py
Guess which one Python thinks pandas wants to import? :-) Rename your program, and remove any .pyc or .pyo files that are around.
I experienced this same problem after upgrading Jupyter, but did not have a local file named numpy.py. I was able to fix the issue on an Anaconda build by uninstalling/reinstalling pandas using: conda remove pandas and then conda install pandas
Problem was fixed.
I meet the some error, but the error for my situation is in mmcv library. I solve it with
pip install --upgrade packaging
here is reference link, hope this could help you.
Related
I am trying to use OpenNMT-py with python 2.7. OpenNMT-py requires torchtext, so I installed it but now when I am running my program, I am getting the following error message.
Traceback (most recent call last):
File "examples/StackPointerParser.py", line 23, in <module>
from neuronlp2.io import get_logger, conllx_stacked_data
File "./neuronlp2/__init__.py", line 7, in <module>
from . import models
File "./neuronlp2/models/__init__.py", line 4, in <module>
from .parsing import *
File "./neuronlp2/models/parsing.py", line 15, in <module>
from onmt.modules import LayerNorm, Transformer
File "/home/wasiahmad/software/anaconda2/lib/python2.7/site-packages/onmt/__init__.py", line 1, in <module>
import onmt.io
File "/home/wasiahmad/software/anaconda2/lib/python2.7/site-packages/onmt/io/__init__.py", line 1, in <module>
from onmt.io.IO import collect_feature_vocabs, make_features, \
File "/home/wasiahmad/software/anaconda2/lib/python2.7/site-packages/onmt/io/IO.py", line 8, in <module>
import torchtext.data
File "/home/wasiahmad/software/anaconda2/lib/python2.7/site-packages/torchtext/__init__.py", line 1, in <module>
from . import data
File "/home/wasiahmad/software/anaconda2/lib/python2.7/site-packages/torchtext/data/__init__.py", line 4, in <module>
from .field import RawField, Field, ReversibleField, SubwordField, NestedField, LabelField
File "/home/wasiahmad/software/anaconda2/lib/python2.7/site-packages/torchtext/data/field.py", line 61, in <module>
class Field(RawField):
File "/home/wasiahmad/software/anaconda2/lib/python2.7/site-packages/torchtext/data/field.py", line 115, in Field
torch.float32: float,
AttributeError: 'module' object has no attribute 'float32'
I tried to look for a solution to resolve this issue but couldn't find any. Any help would be appreciated.
This is more a guess, as you have not given information about your version. But it seems to me that your torchtext version is not compatible with your PyTorch version.
Probably when you installed torchtext you got the newer version already made for PyTorch 0.4.0. But your PyTorch version installed is still older than 0.4.0 (version 0.3.1 or so).
If that is the case you have two options. Downgrading torchtext to a version compatible to yours (probably the version before). Or upgrading PyTorch to version 0.4.0.
I hope this helps.
What's your pytorch version? As per the readme of the github repo of torchtext :
For PyTorch versions before 0.4.0, please use pip install torchtext==0.2.3.
I was facing this exact problem with pytorch 0.3.1 and torchtext 0.3.0. I uninstalled torchtext and then installed it with
pip install torchtext==0.2.3.
And it worked for me. Let me know if you face any other problems.
I'm using spyder 2 anaconda 2.3.0 on windows as a python IDE for python 2.7. I've been using this for a long time to code in python but suddenly I don't know what happened and it said I did not have biopython package installed, when I installed biopython using
conda -c install anaconda biopython
command, biopython started running however it broke pandas and numpy.
now when I import pandas I get this:
>>> import pandas as pd
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Anaconda\lib\site-packages\pandas\__init__.py", line 13, in
<module>
"extensions first.".format(module))
ImportError: C extension: hashtable not built. If you want to import pandas
from the source directory, you may need to run 'python setup.py build_ext --
inplace' to build the C extensions first.
and then when I import numpy I get this:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Anaconda\lib\site-packages\numpy\__init__.py", line 142, in <module>
from . import add_newdocs
File "C:\Anaconda\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "C:\Anaconda\lib\site-packages\numpy\lib\__init__.py", line 8, in <module>
from .type_check import *
File "C:\Anaconda\lib\site-packages\numpy\lib\type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "C:\Anaconda\lib\site-packages\numpy\core\__init__.py", line 26, in <module>
raise ImportError(msg)
ImportError:
Importing the multiarray numpy extension module failed. Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control). Otherwise reinstall numpy.
Original error was: DLL load failed: The specified module could not be found.
I uninstalled numpy and pandas and then installed them back using pip ... still the same. I entirely unistalled anaconda and installed it back still the same errors. I really do not know what's causing this. Any help will be truly appreciated. I've been trying to fix this for the past three days and its not working out. Thanks for your time.
I get the following error when trying to import anydbm in python 2.7.6. Does anyone know whats going wrong? Appreciate your help.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/anydbm.py", line 50, in <module>
_errors.append(_mod.error)
AttributeError: 'module' object has no attribute 'error'
Try dbm it should work. I know in Python3 anydbm to dbm has been renamed.
import dbm
Reloading the information about available software in Ubuntus Software & Updates GUI fixed the problem.
i have installed matplotlib using pip in ubuntu 14.04 LTS.. but on running dispersion_plot this is showing the following error ..
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/nltk/text.py", line 455, in dispersion_plot
from nltk.draw import dispersion_plot
ImportError: cannot import name dispersion_plot
I am new to python... can anyone suggest if there is a better way of installing matplotlib in nltk.
The examples of the online book are not quite right.
You may try this:
from nltk.draw.dispersion import dispersion_plot
words = ['Elinor', 'Marianne', 'Edward', 'Willoughby']
dispersion_plot(gutenberg.words('austen-sense.txt'), words)
You may also call it from a text directly:
from nltk.book import text1
from nltk.draw.dispersion import dispersion_plot
dispersion_plot(text1, ['monstrous'])
this way you import the function directly instead of calling the funcion from text object.
I realized this watching at the source code directly.
Hope this work for you
After importing it using spyder, this is how the plot would look.
I was able to build and install Pydoop without errors, so, for example, I can do the following:
>>> import pydoop
>>> pydoop.__version__
'0.10.0'
However, when I try to import main Pydoop modules such as pipes or hdfs I'm getting ImportError:
>>> import pydoop.hdfs
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "pydoop/hdfs/__init__.py", line 79, in <module>
from fs import hdfs, default_is_local
File "pydoop/hdfs/fs.py", line 28, in <module>
hdfs_ext = pydoop.import_version_specific_module("_hdfs")
File "pydoop/__init__.py", line 111, in import_version_specific_module
return import_module(complete_mod_name(name))
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
ImportError: No module named _hdfs_2_0_0_cdh_4_3_0
In addition, when I try to use pydoop script I'm getting such a hint:
...
ImportError: /usr/local/lib/python2.7/dist-packages/pydoop/_pipes_2_0_0_cdh_4_3_0.so: undefined symbol: BIO_s_mem
BIO_s_mem is a symbol from libssl (OpenSSL), so I guess Pydoop can't find this shared library. I made sure it is available, ends with .so (as opposed to, say, .so.1) and is in LD_LIBRARY_PATH.
So what may be the reason for this error? How can I fix it (build options? environment variables?)
Any help is appreciated.
What OS version are you using? Try setting LD_PRELOAD to the path of your libssl, e.g.:
export LD_PRELOAD=/lib/x86_64-linux-gnu/libssl.so.1.0.0
Not sure about the pipes error, but I ran into your issue with _hdfs_2_0_0_cdh_4_3_0 (mine was a different version of hadoop, but I believe the problem is similar).
The setup.py script seems to want to make an egg file in /usr/local/lib/python2.7/dist-packages for pydoop, but the setup requires that it just be a folder (which will have that _hdfs_2_0_0_cdh_4_3_0.so file in it).
The solution is pretty simple: just delete /usr/local/lib/python2.7/dist-packages/pydoop-0.11.1.egg-info or the equivalent for you version.