Skip to content

ValueError: module functions cannot set METH_CLASS or METH_STATIC #23040

Closed
@joh

Description

@joh

Code Sample, a copy-pastable example if possible

import matplotlib.pyplot as plt
import pandas as pd

Problem description

If I import pyplot before pandas, I get the following error:

Traceback (most recent call last):
  File "bug_pandas.py", line 2, in <module>
    import pandas as pd
  File "/home/joh/.local/lib/python3.6/site-packages/pandas/__init__.py", line 57, in <module>
    from pandas.io.api import *
  File "/home/joh/.local/lib/python3.6/site-packages/pandas/io/api.py", line 19, in <module>
    from pandas.io.packers import read_msgpack, to_msgpack
  File "/home/joh/.local/lib/python3.6/site-packages/pandas/io/packers.py", line 69, in <module>
    from pandas.util._move import (
ValueError: module functions cannot set METH_CLASS or METH_STATIC

If I re-order the imports so that pandas is imported first, the error disappears. Not sure if this is an issue with pyplot or pandas, but the exception seems to come from within pandas.

Expected Output

Output of pd.show_versions()

INSTALLED VERSIONS ------------------ commit: None python: 3.6.6.final.0 python-bits: 64 OS: Linux OS-release: 4.18.8-041808-generic machine: x86_64 processor: x86_64 byteorder: little LC_ALL: en_US.UTF-8 LANG: en_US.UTF-8 LOCALE: en_US.UTF-8

pandas: 0.23.4
pytest: 3.8.0
pip: 9.0.1
setuptools: 40.4.3
Cython: None
numpy: 1.15.2
scipy: 0.19.1
pyarrow: None
xarray: None
IPython: 5.5.0
sphinx: 1.6.7
patsy: None
dateutil: 2.7.3
pytz: 2018.5
blosc: None
bottleneck: 1.2.0
tables: 3.4.2
numexpr: 2.6.4
feather: None
matplotlib: 2.1.1
openpyxl: 2.4.9
xlrd: 1.1.0
xlwt: None
xlsxwriter: None
lxml: 4.2.1
bs4: 4.6.0
html5lib: 0.999999999
sqlalchemy: 1.1.11
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs InfoClarification about behavior needed to assess issueVisualizationplotting

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions