hm8
hm8

Reputation: 1513

Starting Spyder via Windows taskbar and Anaconda prompt results in different environmental variables loaded

If I open Spyder via the window taskbar (i.e clicking on the search button in the lower left, typing "spyder", and clicking on the app), I can get a list of environmental variables with list(os.environ.keys())

If I then open Spyder through an Anaconda Prompt (i.e. opening an Anaconda Prompt window, typing in "spyder", and hitting enter), and do the same thing, several extra environmental variables show up.

These are the variables which show up in list(os.environ.keys()) in Spyder opened through the Anaconda Prompt, but do not appear in the Spyder instance opened through the Windows taskbar:

['CONDA_DEFAULT_ENV',
 'CONDA_EXE',
 'CONDA_PROMPT_MODIFIER',
 'CONDA_PYTHON_EXE',
 'CONDA_SHLVL',
 'GDAL_DATA',
 'GEOTIFF_CSV',
 'PROJ_LIB',
 'PROJ_NETWORK',
 'PROMPT']

I want all of these above to also be set when I open Spyder through the taskbar. Specifically, I need the 'GDAL_DATA' variable to be set.

What's going on, and how can I fix it?

Thanks.

Upvotes: 1

Views: 567

Answers (1)

David Robinson
David Robinson

Reputation: 36

I'm not sure, but when opening Anaconda, it initializes the environments for you. Using Spyder by itself means your python environment needs to be initialized manually. I use a batch file to open environments.

@call C:\path-to\.virtualenvs\Scripts\activate.bat base
@start \path-to\spyder.exe

activate.bat activates the environment base. Assign a shortcut on your desktop to run the batch file.

Upvotes: 1

Related Questions