I want to use gdal to read raster files. This is a mess for me now because I literally reinstalled everything and went over almost all the posts trying all the installation methods and environment changes. Please help, I am a somewhat new to Python, recently switched from MATLAB.

I see I have multiple installations and environments:

base                  *  /Users/name/anaconda3
                         /opt/anaconda3

And I know I need to work in /opt/anaconda3 to do my stuff on Spyder. I need gdal and it is there, I an see it with conda list.

Is there a way to change the base environment? I wanted to keep it simple like one environment one python, Anaconda-Spyder uses the same too but ruined it for my self.

Macbook Processor: 2.6 GHz 6-Core Intel Core i7

In Spyder -Python 3.11.5 (main, Sep 11 2023, 08:19:27) [Clang 14.0.6 ] -IPython 8.15.0 -- An enhanced Interactive Python.

In Terminal -conda 23.7.4 -zsh: command not found: python

It just started working after I toggled between Python interpreters. I did import gdal and it did not give me any error, I know I should have stopped there. At the same time I was frantically going over all the posts and I made a mistake of writing sys.path in my code and it started giving me the same error again: ModuleNotFoundError: No module named 'gdal'

I tried all interpreters, activating all the environments restarting and changing interpreters in Spyder and so on.

In Spyder I typed print(os.environ['CONDA_DEFAULT_ENV']) it gives 'base' as an answer and I think it should be /opt/anaconda3. When I type print(os.environ["CONDA_PREFIX"]), it gives '/Users/name/anaconda3' as the output.

0

There are 0 best solutions below