I have installed and used pysal before on both Windows and Linux Mint. Both of those times I used conda distribution and had no issues installing and running the package. Lately, I have been using Fedora as a primary OS and pip3 to manage python3 packages.
I tried installing via the following commands:
The installations were all successful and were imported normally (no errors) into python. However, when running Python3 kernel, the pysal.open.check() command returns _AttributeError: module 'pysal' has no attribute 'open'_ (the same command on Python2 kernel works just fine). I am not sure what causes this error.
Here is the stack I am using:
Fedora >> 30; kernel: 5.1.20-300.fc30.x86_64
python >> 3.7.4
numpy >> 1.16.4
scipy >> 1.2.0
I also noticed that once I open the '__init__.py' in the python3 installed directory '/usr/local/lib/python3.7/site-packages/pysal' the content of the file is just 4 lines:
__version__='2.1.0'
from . import lib
from . import explore
from . import viz
from . import model
I ended up having to force install version 1.14.4, which now seems to be working fine.
As of version 2.0.0 there has been a major refactoring of PySAL. One upshot of this is taht 1.14.4 is the last python 2.0 version we will support (only with bugfix releases). pysal >= 2.0.0 is python 3 only.
Thank you for the clarification @sjsrey ! I was not aware of the refactoring that happened, possibly because a few pysal workshops that I followed came in pre-2.0 version syntax.
I have the same issue in Ubuntu 18 with pipenv. It is running python 3.6.8 and installed pysal version 2.1.0. The install seems fine.
This raises an AttributeError:
pysal.open.check()
This works fine:
pysal.lib.io.open.check()
It seems like the functions are all there, but the top-level __init__.py isn't passing along nested imports somehow.
>>> pysal
<module 'pysal' from '/home/mike/.local/share/virtualenvs/tmp-gPS56xMp/lib/python3.6/site-packages/pysal/__init__.py'>
I have the same issue as @mfschmidt on windows as well running python 3.7.4 and pysal 2.2.1
Best workaround ive had is to be explicit in calling methods from their modules. See below for examples.
import pysal as ps
ps.lib.examples.available()
ps.explore.esda.Moran()
ps.explore.giddy.markov.Markov()
ps.model.spreg.OLS()
ps.viz.mapclassify.BoxPlot()
or you can be explicit in your import if you only need to use one specific module
import pysal.explore as ps
ps.esda.Moran()
Either way, it doesnt hurt to be a little verbose
Hope this helps if anyone runs into the same issue
Most helpful comment
I have the same issue in Ubuntu 18 with pipenv. It is running python 3.6.8 and installed pysal version 2.1.0. The install seems fine.
This raises an AttributeError:
This works fine:
It seems like the functions are all there, but the top-level __init__.py isn't passing along nested imports somehow.