• Home
  • Jobs
  • Courses
  • Questions
  • Teachers
  • For business
  • ES/EN

0

319
Views
Pandas importing error " ImportError: cannot import name 'DtypeArg' from 'pandas._typing' "

When I try to import pandas, it throws an error. I cannot import pandas. I re-install pandas but it keeps ont throwing the same error.

I tried running it in a local prompt and in a jupyter notebook. I think it may conflict with the pip version so I removed the package from pip. Currently I just have the conda version but still same error. What can I do?

 Traceback (most recent call last):
  File "havatahmin.py", line 1, in <module>
    import pandas as pd
  File "C:\Anaconda\envs\ED\lib\site-packages\pandas\__init__.py", line 144, in <module>
    from pandas.io.api import (
  File "C:\Anaconda\envs\ED\lib\site-packages\pandas\io\api.py", line 8, in <module>
    from pandas.io.excel import ExcelFile, ExcelWriter, read_excel
  File "C:\Anaconda\envs\ED\lib\site-packages\pandas\io\excel\__init__.py", line 1, in <module>
    from pandas.io.excel._base import ExcelFile, ExcelWriter, read_excel
  File "C:\Anaconda\envs\ED\lib\site-packages\pandas\io\excel\_base.py", line 33, in <module>
    from pandas.io.parsers import TextParser
  File "C:\Anaconda\envs\ED\lib\site-packages\pandas\io\parsers\__init__.py", line 1, in <module>
    from pandas.io.parsers.readers import (
  File "C:\Anaconda\envs\ED\lib\site-packages\pandas\io\parsers\readers.py", line 17, in <module>
    from pandas._typing import (
ImportError: cannot import name 'DtypeArg' from 'pandas._typing' (C:\Anaconda\envs\ED\lib\site-packages\pandas\_typing.py)

error

4 months ago ·

Santiago Trujillo

2 answers
Answer question

0

I confirm, it is a reproducible bug in pandas==1.3.1.

A workaround is to downgrade it to some earlier version, e.g. pip install pandas==1.3.0.

The woarkaround can be tested in build 20210717 of our python (3.8) CUDA-enabled containers:

docker run -d --rm --name ml-gpu-py38-cuda112-cust -p 8888:8888 -v /home/mir:/home/jovyan mirekphd/ml-gpu-py38-cuda112-cust:20210717 && docker logs -f ml-gpu-py38-cuda112-cust

Has it been already reported to pandas devs on Github?

Update: The issue still persists, so I've provided a reproducible example to Pandas devs in #42506.

4 months ago · Santiago Trujillo Report

0

This error can occur for multiple reasons.

  • pip install pandas --ignore-installed will break pandas between 1.3.0 and 1.3.1 because it does not remove old files from site-packages, thus the import error. If this is the case, you can re-install pandas without this flag.
pip install --force-reinstall pandas
  • Mixing conda and pip may also break pandas, as discussed here. For that matter, if you use conda, try to stick with it then install missing packages with pip. More guidelines on how to use pip in a Conda environment.
4 months ago · Santiago Trujillo Report
Answer question
Find remote jobs
Loading

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post job Plans Our process Sales
Legal
Terms and conditions Privacy policy
© 2022 PeakU Inc. All Rights Reserved.