You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am installing a package that uses pyasdf. I am a bit limited in the python version I can use. Only version 3.7.4 is available. I was just following instructions I was given which, among many other things, said I should run:
python3 -c "import pyasdf; pyasdf.print_sys_info()"
It failed in watermark.py, telling me I needed obspy even though i had installed obspy using pip (unfortunately it is difficult for me to use Anaconda on this machine). As you may know, watermark uses pkg_resources to get the version numbers of required modules. I did a little digging, and although I can't seem to find it again, somewhere on python.org there were instructions for transitioning from pkg_resources, which is being deprecated, to importlib. Unfortunately for me I couldn't find anything in importlib for 3.7.4 that would give me module version numbers (it is in importlib for 3.9).
Aside from pkg_resources being deprecated, it and/or its combination with pip just weren't working for me in python 3.7.4. Perhaps I should have used something other than pip to install.
So in the end I replaced the following in watermark.py:
watermark["module_versions"] = {
module: get_distribution(module).version for module in modules
}
with:
from pip._internal.operations.freeze import freeze
watermark["module_versions"] = {}
for requirement in freeze(local_only=False):
pkg = requirement.split('==')
if pkg[0] in modules:
watermark["module_versions"][pkg[0]] = pkg[1]
I have no idea if this is a good way to do it, but it worked for me so maybe it might help someone else using python 3.7.4. Also, I thought I'd point out the need (apparently) to eventually switch from pkg_resources to importlib.
The text was updated successfully, but these errors were encountered:
thanks a lot of the detailed report and the elaboration of what is going on.
You are right - we'll definitely have to switch to importlib at some time in the future. I'll let this rest for now for two reasons:
Not a critical part of pyasdf - the print_sys_info() function is really only useful for debugging purposes.
I did not investigate but according to your findings there does not seem to be a proper way to do this yet across Python versions without relying on some internal pip function which I don't think is the best idea.
I also just tried this with a clean Python 3.9 environment and pkg_resources still seems to work fine.
I'll leave this issue open because this will have to be tackled at one point.
I am installing a package that uses pyasdf. I am a bit limited in the python version I can use. Only version 3.7.4 is available. I was just following instructions I was given which, among many other things, said I should run:
python3 -c "import pyasdf; pyasdf.print_sys_info()"
It failed in watermark.py, telling me I needed obspy even though i had installed obspy using pip (unfortunately it is difficult for me to use Anaconda on this machine). As you may know, watermark uses pkg_resources to get the version numbers of required modules. I did a little digging, and although I can't seem to find it again, somewhere on python.org there were instructions for transitioning from pkg_resources, which is being deprecated, to importlib. Unfortunately for me I couldn't find anything in importlib for 3.7.4 that would give me module version numbers (it is in importlib for 3.9).
Aside from pkg_resources being deprecated, it and/or its combination with pip just weren't working for me in python 3.7.4. Perhaps I should have used something other than pip to install.
So in the end I replaced the following in watermark.py:
watermark["module_versions"] = {
module: get_distribution(module).version for module in modules
}
with:
from pip._internal.operations.freeze import freeze
watermark["module_versions"] = {}
for requirement in freeze(local_only=False):
pkg = requirement.split('==')
if pkg[0] in modules:
watermark["module_versions"][pkg[0]] = pkg[1]
I have no idea if this is a good way to do it, but it worked for me so maybe it might help someone else using python 3.7.4. Also, I thought I'd point out the need (apparently) to eventually switch from pkg_resources to importlib.
The text was updated successfully, but these errors were encountered: