Skip to content

BUG: Importing pandas with warnings("error") fails #22788

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jebob opened this issue Sep 20, 2018 · 3 comments
Closed

BUG: Importing pandas with warnings("error") fails #22788

jebob opened this issue Sep 20, 2018 · 3 comments
Labels
CI Continuous Integration

Comments

@jebob
Copy link
Contributor

jebob commented Sep 20, 2018

Code Sample, a copy-pastable example if possible

import warnings
warnings.simplefilter("error")  # causes below line to fail, comment out to succeed without warning
import pandas as pd  

Problem description

Enabling warnings.simplefilter("error") causes pandas to raise an error

Traceback (most recent call last):
  File "C:/Projects/aereseu/jebob/eu/models/bm.py", line 4, in <module>
    import pandas as pd
  File "C:\Python36\lib\site-packages\pandas\__init__.py", line 26, in <module>
    from pandas._libs import (hashtable as _hashtable,
  File "C:\Python36\lib\site-packages\pandas\_libs\__init__.py", line 4, in <module>
    from .tslib import iNaT, NaT, Timestamp, Timedelta, OutOfBoundsDatetime
  File "pandas\_libs\tslibs\conversion.pxd", line 11, in init pandas._libs.tslib
  File "pandas\_libs\tslibs\conversion.pyx", line 1, in init pandas._libs.tslibs.conversion
  File "pandas\_libs\tslibs\nattype.pyx", line 14, in init pandas._libs.tslibs.nattype
ImportWarning: can't resolve package from __spec__ or __package__, falling back on __name__ and __path__

Running python with the command line option Werror results in the same behaviour.

Expected Output

Pandas should not crash when being imported. This is relevant for my use case where I am doing unit testing with -Werror enabled.

Output of pd.show_versions()

INSTALLED VERSIONS ------------------ commit: None python: 3.6.2.final.0 python-bits: 64 OS: Windows OS-release: 10 machine: AMD64 processor: Intel64 Family 6 Model 94 Stepping 3, GenuineIntel byteorder: little LC_ALL: None LANG: None LOCALE: None.None pandas: 0.23.4 pytest: 3.8.0 pip: 18.0 setuptools: 38.4.0 Cython: 0.28.5 numpy: 1.15.1 scipy: 1.1.0 pyarrow: None xarray: None IPython: 6.3.1 sphinx: None patsy: 0.5.0 dateutil: 2.7.3 pytz: 2018.5 blosc: None bottleneck: None tables: None numexpr: None feather: None matplotlib: 3.0.0 openpyxl: 2.4.8 xlrd: 1.1.0 xlwt: None xlsxwriter: None lxml: 4.2.1 bs4: 4.6.0 html5lib: 1.0.1 sqlalchemy: None pymysql: None psycopg2: None jinja2: 2.10 s3fs: None fastparquet: None pandas_gbq: None
@jebob jebob changed the title Importing pandas with warnings("error") fails BUG: Importing pandas with warnings("error") fails Sep 20, 2018
@TomAugspurger
Copy link
Contributor

Blocked by cython/cython#1720 I think.

$ python -W error
>>> import warnings
>>> warnings.filterwarnings("ignore", category=ImportWarning)
>>> import pandas

If this is important to you, you could add a small script to our CI to ensure that pandas can be imported without warnings.

@TomAugspurger TomAugspurger added the CI Continuous Integration label Sep 20, 2018
@jebob
Copy link
Contributor Author

jebob commented Sep 20, 2018

This solves my issue, thanks for the quick response.

@TomAugspurger TomAugspurger modified the milestones: no i, No action Sep 20, 2018
@TomAugspurger
Copy link
Contributor

Closing, but if someone wants to add a test for this that's probably OK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI Continuous Integration
Projects
None yet
Development

No branches or pull requests

2 participants