Working Python, Obspy, Cartopy Versions

I’ve struck some problems and had to reinstall Python, and now I can’t find a working version combination of python, obspy and cartopy. It seems Python, Numpy and Cartopy have been updated and deprecated functions that Obspy needs.

So if you have a working setup could you please advise:
What version of Python are you using?
What version of Obspy are you using?
What version of Cartopy are you using?

Thanks,
Al.

1 Like

Hello Al,

Yeah, I hated it when that happened to me… I use these:

Python 3.8.13
Obspy 1.4.0
Cartopy 0.18.0

Obspy 1.4.1 should work fine with an updated matplotlib, if this doesn’t break other functions you have in your code.

1 Like

Thanks Stormchaser.

I’ll give that a whirl. I know I was using python 3.9.12, but couldn’t recall the versions for Obspy and Cartopy. I had installed with Anaconda which looks after the compatibilities, but it developed problems, where it wouldn’t let me create new environments, or perform updates, etc. I installed another package for another citizen science project and it all crashed. So I’m going back to pip.

Al.

2 Likes

Yeah, after a bit, you either need to completely uninstall/delete everything Anaconda-related and perform a clean reinstall…

I usually have two environments, one for production (the main one) and one for development.

The two are basically copies of each other, but if I have to test some new module, I’ll just do it in dev first because I’ve been where you are now, and reinstalling 50+ Python modules in the correct versions was not fun…

But, every now and then, I have to clean up all my .yml env backup files… they tend to grow, exponentially!

1 Like

I’m still having an issue with Cartopy now.

I have created a new virtual environment with Python 3.9.12 and successfully installed Obspy 1.4.1, but Cartopy installation is crashing because there is no “convert_path” in

init.py
in the virtual environment folder.

I have tried various versions of Cartopy, with basically the same result.

Stormchaser could you please have a look in your

init.py
file and see what is required for convert_path? Maybe I can add an appropriate path.

Thanks,

Al.

1 Like

Sorry I can’t get it to display the underscores in the filename. The correct filename is in the screenshot.

Al.

1 Like

I have installed:

Python - 3.11.2
Obspy - 1.4.1
Cartopy - 0.24.1

I had no problems related to Cartopy. The only issue was related to Obspy making depreciated calls to Numpy (2.1.2), Once I changed all instances of “np.float_” to “np.float64” (in files in “lib/python3.11/site-packages/obspy/taup”) everything worked as expected.

3 Likes

Hello Al,

In fact, I could not find a convert_path element in setuptools/__init__.py (you can add underscores if you enclose the text in “``” -without the external quotation marks).

Maybe you can try dlfowler’s solution in a temporary new environment and see if it works with all your other Python modules.

1 Like

Thanks. I am still persisting… I may have to try a different installation sequence.

Al.

1 Like

Thanks @dlfowler you provided the key.

For some reason I could not install a specified version of Cartopy with pip, so I did the install without specifying the version and then made the changes you suggested. I ended up with:

Python v3.9.12
Obspy v1.4.1
Cartopy v0.23.0

All working perfectly ATM.

The only other change I had to make to my code was change all references to


def divTrace(tr, n):            # divide trace into n equal parts for background noise determination
    return tr.__div__(n)

to


def divTrace(tr, n):            # divide trace into n equal parts for background noise determination
    return tr.__truediv__(n)

Thanks to both you and @Stormchaser for all your help!

Al.

2 Likes

Happy to help Al, and we’re always learning something new!

1 Like