cannot import 'ParserError' from 'dateutil.parser' - python

I am trying to import pandas in my code and it throws the following error.
>>> import pandas
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/gopika/.local/lib/python3.8/site-packages/pandas/__init__.py", line 48, in <module>
from pandas.core.api import (
File "/home/gopika/.local/lib/python3.8/site-packages/pandas/core/api.py", line 22, in <module>
from pandas.core.algorithms import (
File "/home/gopika/.local/lib/python3.8/site-packages/pandas/core/algorithms.py", line 39, in <module>
from pandas.core.dtypes.cast import (
File "/home/gopika/.local/lib/python3.8/site-packages/pandas/core/dtypes/cast.py", line 24, in <module>
from dateutil.parser import ParserError
ImportError: cannot import name 'ParserError' from 'dateutil.parser' (/usr/lib/python3/dist-packages/dateutil/parser/__init__.py)
I tried reinstalling python-dateutil but this doesn't solve the issue. I am not very sure what has changed in my enviroment but pandas was working normally and one day it suddenly start showing this error. It will be great if someone can help me with this. Thanks!

from dateutil.parser import ParserError
You defined, or installed, a dateutil module.
And it isn't this one:
https://pypi.org/project/python-dateutil 2.8.2
Rename / reinstall so the import succeeds.

Related

Pandas, Numpy Erorr after installing them

After installing pandas and some other dependencies, this error occurred when I ran my program.
Traceback (most recent call last):
File "/home/nielson-scientific/schreiber-uv-led-sterilization-system/src/main.py", line 8, in <module>
from Tabs.SystemHistory import SystemHistory
File "/home/nielson-scientific/schreiber-uv-led-sterilization-system/src/Tabs/SystemHistory.py", line 9, in <module>
from Utils.CSV import CsvData
File "/home/nielson-scientific/schreiber-uv-led-sterilization-system/src/Utils/CSV.py", line 7, in <module>
import pandas as pd
File "/home/nielson-scientific/.local/lib/python3.9/site-packages/pandas/__init__.py", line 22, in <module>
from pandas.compat import is_numpy_dev as _is_numpy_dev
File "/home/nielson-scientific/.local/lib/python3.9/site-packages/pandas/compat/__init__.py", line 15, in <module>
from pandas.compat.numpy import (
File "/home/nielson-scientific/.local/lib/python3.9/site-packages/pandas/compat/numpy/__init__.py", line 4, in <module>
from pandas.util.version import Version
File "/home/nielson-scientific/.local/lib/python3.9/site-packages/pandas/util/__init__.py", line 1, in <module>
from pandas.util._decorators import ( # noqa:F401
File "/home/nielson-scientific/.local/lib/python3.9/site-packages/pandas/util/_decorators.py", line 14, in <module>
from pandas._libs.properties import cache_readonly # noqa:F401
File "/home/nielson-scientific/.local/lib/python3.9/site-packages/pandas/_libs/__init__.py", line 13, in <module>
from pandas._libs.interval import Interval
File "pandas/_libs/interval.pyx", line 1, in init pandas._libs.interval
ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 48 from C header, got 40 from PyObject
I have tried upgrading the version of numpy and that printed out new different error saying numpy import error.
nielson-scientific#pi:~/schreiber-uv-led-sterilization-system $ python3 src/main.py
Traceback (most recent call last):
File "/home/nielson-scientific/schreiber-uv-led-sterilization-system/src/main.py", line 8, in <module>
from Tabs.SystemHistory import SystemHistory
File "/home/nielson-scientific/schreiber-uv-led-sterilization-system/src/Tabs/SystemHistory.py", line 9, in <module>
from Utils.CSV import CsvData
File "/home/nielson-scientific/schreiber-uv-led-sterilization-system/src/Utils/CSV.py", line 7, in <module>
import pandas as pd
File "/home/nielson-scientific/.local/lib/python3.9/site-packages/pandas/__init__.py", line 16, in <module>
raise ImportError(
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. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
* The Python version is: Python3.9 from "/usr/bin/python3"
* The NumPy version is: "1.22.4"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: libcblas.so.3: cannot open shared object file: No such file or directory
Anyone have Idea how to fix this?

functools has no attribute lru_cache

I'm using Python 3.7 on my Windows
This error occurs while running every code:
Traceback (most recent call last):
File "test.py", line 1, in <module>
import nltk
File "C:\Users\HP\AppData\Local\Programs\Python\Python37\lib\site-packages\nltk\__init__.py", line 99, in <module>
from nltk.internals import config_java
File "C:\Users\HP\AppData\Local\Programs\Python\Python37\lib\site-packages\nltk\internals.py", line 11, in <module>
import subprocess
File "C:\Users\HP\AppData\Local\Programs\Python\Python37\lib\subprocess.py", line 50, in <module>
import signal
File "C:\Users\HP\AppData\Local\Programs\Python\Python37\lib\signal.py", line 3, in <module>
from functools import wraps as _wraps
File "C:\Users\HP\AppData\Local\Programs\Python\Python37\lib\functools.py", line 21, in <module>
from collections import namedtuple
File "C:\Users\HP\AppData\Local\Programs\Python\Python37\lib\collections\__init__.py", line 22, in <module>
from keyword import iskeyword as _iskeyword
File "C:\Users\HP\Desktop\tweepy\keyword.py", line 1, in <module>
import re
File "C:\Users\HP\AppData\Local\Programs\Python\Python37\lib\re.py", line 297, in <module>
#functools.lru_cache(_MAXCACHE)
AttributeError: module 'functools' has no attribute 'lru_cache'
How to fix it?
It looks like someone published a functools package on pypi, so if you had run:
# don't run this!
pip install functools
You may have accidentally installed that package. If you encounter this error, I would:
pip uninstall functools
To make sure that the functools you are using are the base package functools.
(I ended up here because I attempted to use functools.cache, which seems to only be present in Python 3.8, not earlier.)
I had the same error recently and it was because I had a file called functools.py in my project. Renaming it fixed the issue.

ImportError: cannot import name 'binary_type'

I've installed BSON library to convert strings to MongoDB ObjectIds, but when I try using the library, this comes up:
Traceback (most recent call last):
File "search.py", line 7, in <module>
from pymongo.mongo_client import MongoClient
File "/home/user/anaconda3/lib/python3.6/site-packages/pymongo/__init__.py", line 90, in <module>
from pymongo.common import (MIN_SUPPORTED_WIRE_VERSION,
File "/home/user/anaconda3/lib/python3.6/site-packages/pymongo/common.py", line 21, in <module>
from pymongo.auth import MECHANISMS
File "/home/user/anaconda3/lib/python3.6/site-packages/pymongo/auth.py", line 33, in <module>
from bson.binary import Binary
File "/home/user/anaconda3/lib/python3.6/site-packages/bson/binary.py", line 21, in <module>
from bson.py3compat import PY3, binary_type
ImportError: cannot import name 'binary_type'
Also pip installs py3compat, but there's no 'binary_type' in there.
Any idea how to fix this?
I saw this error and got it fixed by installing the newest version of pymongo.
(at the time of writing)
pip install pymongo==3.5.1

jupyter lab is broken how can I fix it?

I can't figure out why jupyter-lab is not working. something is broken and don't know where. I have searched the web for this and can't find a solution. COuld you please help. Appreciate it.
E:\gitrepos>jupyter lab
`Traceback (most recent call last):
File "E:\anaconda3\Scripts\jupyter-lab-script.py", line 3, in <module>
import jupyterlab.labapp
File "E:\anaconda3\lib\site-packages\jupyterlab\labapp.py", line 7, in <module>
from notebook.notebookapp import NotebookApp, aliases, flags
File "C:\Users\Dario.Romero\AppData\Roaming\Python\Python35\site-packages\notebook\notebookapp.py", line 78, in <module>
from .services.kernels.kernelmanager import MappingKernelManager
File "C:\Users\Dario.Romero\AppData\Roaming\Python\Python35\site-packages\notebook\services\kernels\kernelmanager.py", line 19, in <module>
from jupyter_client.session import Session
File "E:\anaconda3\lib\site-packages\jupyter_client\session.py", line 61, in <module>
from jupyter_client.jsonutil import extract_dates, squash_dates, date_default
File "E:\anaconda3\lib\site-packages\jupyter_client\jsonutil.py", line 11, in <module>
from dateutil.parser import parse as _dateutil_parse
ImportError: No module named 'dateutil.parser'`
You need to install the dateutil library: https://pypi.python.org/pypi/python-dateutil/
(If you used a package manager, the dependencies for JupyterLab should already have been installed. If you didn't, then you will need to install the dependencies yourself.)

Cannot import name StringIO when importing dateutil

I'm having a 'Cannot import name StringIO' error message when importing dateutil which tries to import StringIO but cannot find it. Here is complete trace:
(DEV)arbi#el-oued:~/Work/sentimentpy$ python core/main.py
Traceback (most recent call last):
File "core/main.py", line 7, in <module>
from io.reader import *
File "/home/arbi/Work/sentimentpy/core/io/reader.py", line 4, in <module>
from dateutil import parser
File "/home/arbi/DEV/local/lib/python2.7/site-packages/dateutil/parser.py", line 22, in <module>
from io import StringIO
ImportError: cannot import name StringIO
When I tried to use python3 to launch my program, i had this error:
(DEV)arbi#el-oued:~/Work/sentimentpy$ python3 core/main.py
Traceback (most recent call last):
File "core/main.py", line 1, in <module>
from analyzer.length import LengthAnalyzer
File "/home/arbi/Work/sentimentpy/core/analyzer/length.py", line 4, in <module>
from numpy
ImportError: No module named numpy
Why I'm having this? i've installed numpy in my virtualenv with: pip install numpy
You are masking the built-in io module because you have a package named io in your project:
Traceback (most recent call last):
File "core/main.py", line 7, in <module>
from io.reader import *
File "/home/arbi/Work/sentimentpy/core/io/reader.py", line 4, in <module>
The line from io import StringIO finds /home/arbi/Work/sentimentpy/core/io, not the built-in module.
Rename that package or move it into a new top-level package name that doesn't conflict.
Your second error is unrelated; you simply don't have numpy installed for Python 3.

Categories

Resources