I wrote a python script over the summer that uses NumPy and Pandas to help me code some corpus data for the linguistics/psych lab I work in. All was fine until I upgraded to OSX Mavericks -- since then the script throws the following ImportError:
No module named dateutil.parser
Traceback (most recent call last):
File "/Users/nicholasmoores/Documents/Research/DataFrame_by_child1.9.2.py", line 30, in <module>
import pandas as pd #you will have to go through the potentially arduous process
File "/Library/Python/2.7/site-packages/pandas-0.11.0-py2.7-macosx-10.8-intel.egg/pandas/__init__.py", line 6, in <module>
from . import hashtable, tslib, lib
File "tslib.pyx", line 31, in init pandas.tslib (pandas/tslib.c:48027)
ImportError: No module named dateutil.parser
logout
which is quite frustrating! I don't know why anything else on the script would fail to work after dealing with my imports, and numpy and pandas were the only ones I was expecting to have trouble with after upgrading... FYI I'm now running Python 2.7.6
import os.path
import re
import sys
import nltk
import pickle
import numpy as np
import pandas as pd
from nltk.corpus.reader import CHILDESCorpusReader
from nltk.probability import ConditionalFreqDist, FreqDist
fd = FreqDist()
cfd = ConditionalFreqDist()
I'm sure it has to do with OSX's inhouse python getting upgraded and I suppose Pandas is trying to look for python syntax in the dateutil module that has since changed or something like that. If anyone has any suggestions they would be much appreciated as I was hoping to get a lot of data coded over the holidays!
Dateutil is a dependency of pandas, it looks like somehow this module is no longer on your system.
You'll need to (re)install dateutil:
sudo pip install dateutil
What ended up fixing the problem was redownloading and reinstalling dateutil. I'm still not completely sure where the fault was that caused Pandas to not be able to access it anymore, but I'm glad I got it all working again!
Related
I am trying to import panda in python script .
import pandas as pd
import numpy as np
But I am getting below error :
Error from Scripts is : Script failed to run:
Error: [Traceback (most recent call last):
File "<string>", line 2, in <module>
ModuleNotFoundError: No module named 'pandas'
] (2604) (2603)
This python script I am using in Cortex XSOAR (demisto).
I have to sort values in columns in one table. Google results shows that have to use pandas.DataFrame.sort_values. Hence, using this.
Please help me on fixing error with pandas module import or suggest me if there is any other way I can sort table values based on 1 column i.e integer values
Thanks in advance ,
NVP
Did you install pandas ?
py -m pip install pandas
I would suggest you to check where you installed pandas and use sys to append that path to your code.
For example:
import sys
sys.path.append(r'c:\users\NVP\appdata\local\programs\python\python39\lib\site-packages')
I'm pretty new to Python, but have Python 3.6 installed, and running a few other programs perfectly. I'm trying to pull data using the pandas_datareader module but keep running into this issue. Operating system: OSX.I've visited the other threads on similar errors and tried their methods to no avail.
Additional concern: When using Sublime Text, if I run it as a Python (instead of Python3) build, it funcitons fine, but all my other accompanying programs are written on Python3. Is there a way of making this work on 3.6 that I'm missing?
I have already visited the 'is_list_like' error question, and have changed the fred.py file to pandas.api.types in the import line.
Traceback (most recent call last):
File
"/Users/scottgolightly/Desktop/python_work/data_read_practice.py", line
3, in <module>
import pandas_datareader.data as web
File
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-
packages/pandas_datareader/__init__.py", line 2, in <module>
from .data import (DataReader, Options, get_components_yahoo,
File
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-
packages/pandas_datareader/data.py", line 14, in <module>
from pandas_datareader.fred import FredReader
File
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-
packages/pandas_datareader/fred.py", line 1, in <module>
from pandas.core.common import is_list_like
ImportError: cannot import name 'is_list_like'
As has been noted, is_list_like has been moved from pandas.core.common to pandas.api.types.
There are several paths forward for you.
My (highly) recommended solution: download Conda and set up an environment with a version of Pandas prior to v0.23.0.
You can install the development version of Pandas, with a patch in place:
pip install git+https://github.com/pydata/pandas-datareader.git
Since you say that you have a version of Pandas in a different environment that works, I suspect the Python calling it is version 2.X. If so, try using past.autotranslate to import the older version of Pandas.
If this working version of Pandas actually belongs to a Python 3.X site-packages, then you can manually import it using:
sys.path.insert(0, '/path/to/other/pandas')
Small workaround is to define it like this:
import pandas as pd
pd.core.common.is_list_like = pd.api.types.is_list_like
import pandas_datareader
I know other people went through this kind of problem but I still can't fix the problem. I just began to programming.
I use spyder IDE and get the following error when I run the code.
File "C:\Users\kaany\AppData\Roaming\Python\Python36\site-packages\matplotlib\path.py", line 25, in <module>
from . import _path, rcParams
ImportError: cannot import name '_path'
When I remove 'import matplotlib as plt' from my code everything goes fine.
I have numpy 1.13.3 and matplotlib 2.1.0
I'd appreciate if someone provided any solution to this.
I'm using Python, and just start importing pandas, then the terminal reports failure like this:
Traceback (most recent call last):
File "C:/Users/L30607/PycharmProjects/untitled1/pandas.py", line 1, in <module>
import pandas as pd
Any idea whats wrong?
If you have installed pandas, then your local pandas.py is shadowing the pandas library. To get the original pandas, do:
from __future__ import absolute_import
import pandas as pd
Or save the trouble and just rename your own script to something else: my_pandas.py.
Am trying to run a python script that i downloaded from the internet
import os, subprocess, sys, socket, time, struct, random, xml.sax, getopt
import shutil
import Output
import numpy as np
...
I get the error
Traceback (most recent call last):
File "downtown.py", line 20, in <module>
import Output
ImportError: No module named Output
Am totally new to python , and I want to know whether the missing import is python's or a user library
As a first hint, observe the missing module Output starts with a capital O, which fails to follow convention of using lowercase-only for module names. Therefore Output is most certainly a user library. Alternatively, Output might be a class that would correctly need to be imported via from somelib import Output.
It is not a standard module - it looks like a user module that you should also download from wherever you got the original script.