gimli-org / gimli

Geophysical Inversion and Modeling Library :earth_africa:
https://www.pygimli.org
Other
344 stars 131 forks source link

Issue on importing the Res2dinv export module #687

Closed IsabellaLorenzen closed 1 month ago

IsabellaLorenzen commented 1 month ago

Problem description¨

I wish to export my ERT data into res2dinv. In a previous issue you recommended the following code:

from pybert.importer.exportData import exportRes2dInv exportRes2dInv(data, "filename.dat")

But i struggle to import the exportRed2dInv

Your environment

OS : Windows CPU(s) : 8 Machine : AMD64 Architecture : 64bit RAM : 7.8 GiB Environment : IPython

Python 3.9.18 | packaged by conda-forge | (main, Dec 23 2023, 16:29:04) [MSC v.1929 64 bit (AMD64)]

       pygimli : 1.4.6
        pgcore : 1.4.0
         numpy : 1.26.4
    matplotlib : 3.7.2
         scipy : 1.11.2
       IPython : 8.15.0
       pyvista : 0.43.3

Steps to reproduce

I have tried these commands:

import pygimli as pg
import pybert as pb

from pybert.importer.exportData import exportRes2dInv
from pb.importer.exportData import exportRes2dInv

...
#  Entering pb to the kernel yields this, which must prove that pybert is installed. 
<module 'pybert' from 'C:\\Users\\Isabe\\anaconda3\\envs\\pg\\lib\\site-packages\\pybert\\__init__.py'>

# Output from attempting to import the export module using this code: from pybert.importer.exportData import exportRes2dInv
ModuleNotFoundError: No module named 'pybert.importer'

# Output from attempting to import the export module using this code: from pb.importer.exportData import exportRes2dInv
ModuleNotFoundError: No module named 'pb'

If possible, please add one or more labels to your issue, e.g. if you expect that your issue is rather a question than a problem with the code, please add the label "question".

halbmy commented 1 month ago

How did you install pybert and which version do you have?

IsabellaLorenzen commented 1 month ago

I installed it using pip install pybert and its the 0.0.2 version.

It is a folder i my site packages in the pygimli environment.

halbmy commented 1 month ago

You probably installed some other pybert. Up to now, there is no pip installation of OUR pybert (but there should be one as now pyGIMLi can also be installed by pip). Please use conda install -c gimli pybert or just clone pyBERT by git.

IsabellaLorenzen commented 1 month ago

I am not able to run conda install -c gimli pybert with my current python version (3.11), but to be able to run it i have made a new environment, that will allow be to run the install. The envionment is made with this code: conda create -n pg_newness -c gimli -c conda-forge python=3.8 "pygimli<=1.4.0"

But in spyder when i run only import pygimli as pg and import pybert as pb it yields the following error:

AttributeError: module 'numpy' has no attribute 'float'. np.float was a deprecated alias for the builtin float. To avoid this error in existing code, use float by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use np.float64 here. The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations

(In addition i would like to use the newest version of pygimli as possible. I was succesful in running my code with pygimli 1.3.1 version, but i am using the dataframe .copy() command, and that is not accessable in the 1.3.1 version)

halbmy commented 1 month ago

Why would you want pygimli <= 1.4.0 ? Can you please try with >= 1.5.0 ?

IsabellaLorenzen commented 1 month ago

I didnt think i was able to, but I have now created an environment with conda create -n pg_newness -c gimli -c conda-forge python=3.8 "pygimli<=1.5.0"

When i run each of these import: import pygimli as pg import pybert as pb from pybert.importer.exportData import exportRes2dInv

I still get the error: AttributeError: module 'numpy' has no attribute 'float'. np.float was a deprecated alias for the builtin float. To avoid this error in existing code, use float by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use np.float64 here. The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations

I suspected it had something to do with my numpy version, but i have tried different version from 1.19 to 1.24, and i keep getting the same issue, and i am not even calling any .np commands with just importing pg and pd.

IsabellaLorenzen commented 1 month ago

Hallo again, and sorry for all of the back and forth!

I finally created an environment with conda create -n pg_newness -c gimli -c conda-forge python=3.9 "pygimli<=1.5.0"

And it apprears to all be working now, thank you!

halbmy commented 1 month ago

In this case the <= does not make much sense, did you now install 1.5.0 or 1.4.x?

In any case, we stopped supporting Python<3.9 so fixing to 3.8 was the source of the problem.