Failing to import pandas in Anjuta "module functions cannot set METH_CLASS or METH_STATIC"

I have this boilerplate in a minimal Anjuta app that runs. I do not want to install pandas to the system python path so I am using Virtualenv. When I add import pandas as pd I get the following error message.

Not sure if this is Anjuta or Pandas related. I have googled for the error message but nothing instrumental. What do I do?

#!/home/USERNAME/my_app/bin/python3.6
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, GdkPixbuf, Gdk
import os, sys, gi
...
from shutil import copyfile
import pandas as pd
...

And I get this.

EXECUTING:
/home/USERNAME/my_app/src/my_app.py
----------------------------------------------
Traceback (most recent call last): File "/home/USERNAME/my_app/src/my_app.py", line 35, in <module> import pandas as pd File "/home/USERNAME/my_app/virtualenv_my_app/my_app/lib/python3.6/site-packages/pandas/__init__.py", line 57, in <module> from pandas.io.api import * File "/home/USERNAME/my_app/virtualenv_my_app/my_app/lib/python3.6/site-packages/pandas/io/api.py", line 19, in <module> from pandas.io.packers import read_msgpack, to_msgpack File "/home/USERNAME/my_app/virtualenv_my_app/my_app/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
----------------------------------------------
Program exited with errcode (1)
Press the Enter key to close this terminal ... 

without the import pandas as pd the program runs just fine...

EXECUTING:
/home/USERNAME/my_app/src/my_app.py
----------------------------------------------
/home/USERNAME/my_app/test.xlsx
----------------------------------------------
Program exited with errcode (0)
Press the Enter key to close this terminal ... 

The same import pandas as pd runs fine if used from a command line python script from the same directory and same virtualenv. Also it runs when called via subprocess.call() from Anjuta runmode.

I am on Ubuntu 18.04 and have installed Anjuta with apt, pandas with pip install pandas.

1 Answer

It seems to be a problem with python 3.6; I had the same problem except I was using matlibplot, numpy and pandas with the following order:

import numpy as np
import matplotlib.pyplot as plt
import pandas as pd

And it gave me the same error you got, I rearranged my import order so that it looks like:

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

And now it runs well. See this github issue which is very related: . Quoting the last user who posted as today named "AlfTang":

The problem is fixed it by changing pandas import order as suggested. I suspect that the cause is python3.6. When I used python 3.5.2 everything worked fine.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like