Page MenuHomeSolus

Python ImportError pandas
Open, Needs More InfoPublic

Description

When trying to import pandas on Solus Python returns an ImportError for pandas. The package python-pandas was installed via eopkg just a few minutes ago. The import of pandas is done like this:

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import pandas as pd

The problem was present on a one year old Solus install as well as on a recent install and could not be solved by setting the path to python3 or import pandas as 'python-pandas' as it is named by eopkg.

Event Timeline

Fox created this task.Oct 27 2020, 8:18 AM
livingsilver94 added a subscriber: livingsilver94.EditedOct 27 2020, 8:55 AM

Pandas in Solus only supports Python3: https://dev.getsol.us/source/python-pandas/browse/master/pspec_x86_64.xml$29

Your shabang, #!/usr/bin/env python, is using Python 2 instead. Python 2 is deprecated and should not use it in new projects. Change your shabang to #!/usr/bin/env python3 and it should work.

At any rate, it is discouraged to use system packages for development purposes. Pandas is here only because it is a dependency of some other packages. You'd better use virtual environments to have full control on your dependencies.

Fox added a comment.EditedOct 27 2020, 9:22 AM

Your shabang, #!/usr/bin/env python, is using Python 2 instead. Python 2 is deprecated and should not use it in new projects. Change your shabang to #!/usr/bin/env python3 and it should work.
At any rate, it is discouraged to use system packages for development purposes. [...] You'd better use virtual environments to have full control on your dependencies.

This does not work, as I mentioned in the beginning. Changing to python3 also results in an ImportError.

Nonetheless, thanks for the advice with virtual environments. Maybe this is something for the Help Center to describe. Digging in the forum one finds to not use pip but to use the system packages instead. So I’ll try to figure out how these virtual environments are used.

livingsilver94 added a comment.EditedOct 27 2020, 9:38 AM

Hm, I think something is wrong with your system. This works for me:

#!/usr/bin/env python3
import pandas as pd

print(dir(pd))

Maybe it's worth checking your PYTHONPATH variable? But this is becoming a support thread instead of a bug report and I don't know if I'm allowed to proceed.

DataDrake triaged this task as Needs More Info priority.Nov 14 2020, 4:30 PM