ContinuumIO / anaconda-issues

Anaconda issue tracking
648 stars 222 forks source link

Environment variables for GDAL missing when Spyder is started from Windows start menu #10895

Open itati01 opened 5 years ago

itati01 commented 5 years ago

Actual Behavior

Hi, gdal-based libraries do not correctly identify the projection of geodata if Spyder is started via the Windows start menu (Win 10, Anaconda 2) because the required environment variables are missing. Starting Spyder from Anaconda Navigator or commandline works fine. This behaviour was confirmed with a clean environment. Thanks in advance for any help, Andreas

Expected Behavior

The attached file test.zip contains a GeoTiff with the CRS EPSG:25832.

gdal is expected to report

'PROJCS["ETRS89 / UTM zone 32N",GEOGCS["ETRS89",DATUM["European_Terrestrial_Reference_System_1989",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6258"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4258"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",9],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","25832"]]'

But I get

'LOCAL_CS["ETRS89 / UTM zone 32N",GEOGCS["ETRS89",DATUM["unknown",SPHEROID["unretrievable - using WGS84",6378137,298.257223563],TOWGS84[0,0,0,0,0,0,0]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]],AUTHORITY["EPSG","25832"],UNIT["metre",1,AUTHORITY["EPSG","9001"]]]'

The environment after starting from Anaconda Navigator:

environ{'CONDA_DEFAULT_ENV': 'py3',
        'CONDA_EXE': 'C:\\Users\\*\\Programme\\Anaconda2\\Scripts\\conda.exe',
        'CONDA_PREFIX_1': 'C:\\Users\\*\\Programme\\Anaconda2',
        'CONDA_PROMPT_MODIFIER': '(py3) ',
        'CONDA_PYTHON_EXE': 'C:\\Users\\*\\Programme\\Anaconda2\\python.exe',
        'CONDA_SHLVL': '2',
        'GDAL_DATA': 'C:\\Users\\*\\Programme\\Anaconda2\\envs\\py3\\Library\\share\\gdal',
        'GEOTIFF_CSV': 'C:\\Users\\*\\Programme\\Anaconda2\\envs\\py3\\Library\\share\\epsg_csv',
        'PROJ_LIB': 'C:\\Users\\*\\Programme\\Anaconda2\\envs\\py3\\Library\\share\\proj',
        'PROMPT': '(py3) $P$G',
        'TMP': 'C:\\Users\\gericke\\AppData\\Local\\Temp', ...

After starting via Start Menu:

environ{'TMP': 'C:\\Users\\*\\AppData\\Local\\Temp', ...

Steps to Reproduce

Start Spyder from Start menu

from osgeo import gdal
test = gdal.Open("test.tif")
test.GetProjectionRef()

import os
os.environ
Anaconda or Miniconda version:

Anaconda 2 64 bit

Operating System:

Windows 10 64 bit

conda info
``` active environment : py3 active env location : C:\Users\*\Programme\Anaconda2\envs\py3 shell level : 2 user config file : C:\Users\*\.condarc populated config files : C:\Users\*\.condarc conda version : 4.6.14 conda-build version : 3.17.1 python version : 2.7.15.final.0 base environment : C:\Users\*\Programme\Anaconda2 (writable) channel URLs : https://repo.anaconda.com/pkgs/main/win-64 https://repo.anaconda.com/pkgs/main/noarch https://repo.anaconda.com/pkgs/free/win-64 https://repo.anaconda.com/pkgs/free/noarch https://repo.anaconda.com/pkgs/r/win-64 https://repo.anaconda.com/pkgs/r/noarch https://repo.anaconda.com/pkgs/msys2/win-64 https://repo.anaconda.com/pkgs/msys2/noarch package cache : C:\Users\*\Programme\Anaconda2\pkgs C:\Users\*\.conda\pkgs C:\Users\*\AppData\Local\conda\conda\pkgs envs directories : C:\Users\*\Programme\Anaconda2\envs C:\Users\*\.conda\envs C:\Users\*\AppData\Local\conda\conda\envs platform : win-64 user-agent : conda/4.6.14 requests/2.18.4 CPython/2.7.15 Windows/10 Windows/10.0.17134 administrator : False netrc file : None offline mode : False ```
conda list --show-channel-urls
``` # Name Version Build Channel affine 2.2.2 py_0 conda-forge alabaster 0.7.12 py_0 conda-forge asn1crypto 0.24.0 py37_1003 conda-forge astroid 2.1.0 py37_1000 conda-forge attrs 18.2.0 py_0 conda-forge babel 2.6.0 py_1 conda-forge backcall 0.1.0 py_0 conda-forge blas 1.0 mkl defaults bleach 3.1.0 py_0 conda-forge blosc 1.15.0 h7bd577a_0 defaults boost-cpp 1.68.0 h6a4c333_1000 conda-forge boto3 1.9.96 py_0 conda-forge botocore 1.12.96 py_0 conda-forge bzip2 1.0.6 hfa6e2cd_1002 conda-forge ca-certificates 2019.3.9 hecc5488_0 conda-forge certifi 2019.3.9 py37_0 conda-forge cffi 1.12.1 py37hfa6e2cd_0 conda-forge chardet 3.0.4 py37_1003 conda-forge click 7.0 py_0 conda-forge click-plugins 1.0.4 py_0 conda-forge cligj 0.5.0 py_0 conda-forge cloudpickle 0.7.0 py_0 conda-forge colorama 0.4.1 py_0 conda-forge cryptography 2.5 py37h7a1dbc1_0 defaults curl 7.63.0 h2a8f88b_1000 defaults cycler 0.10.0 py_1 conda-forge cytoolz 0.9.0.1 py37hfa6e2cd_1001 conda-forge dask-core 1.1.1 py_0 conda-forge decorator 4.3.2 py_0 conda-forge defusedxml 0.5.0 py37_1 defaults descartes 1.1.0 py_3 conda-forge docutils 0.14 py37_1001 conda-forge entrypoints 0.3 py37_1000 conda-forge expat 2.2.5 he025d50_1002 conda-forge fiona 1.8.6 py37hce0be61_3 conda-forge freetype 2.9.1 h5db478b_1005 conda-forge freexl 1.0.5 hd288d7e_1002 conda-forge gdal 2.4.1 py37hdf5ee75_2 conda-forge geojson 2.4.1 py_0 conda-forge geopandas 0.5.0 py_2 conda-forge geos 3.7.1 he025d50_1000 conda-forge geotiff 1.5.1 h7bfc4c5_1 conda-forge gettext 0.19.8.1 hb01d8f6_1001 conda-forge glib 2.58.2 hc0c2ac7_1001 conda-forge hdf4 4.2.13 hf8e6fe8_1002 conda-forge hdf5 1.10.4 nompi_hcc15c50_1105 conda-forge icc_rt 2019.0.0 h0cc432a_1 defaults icu 58.2 ha66f8fd_1 defaults idna 2.8 py37_1000 conda-forge imageio 2.5.0 py37_0 conda-forge imagesize 1.1.0 py_0 conda-forge intel-openmp 2019.1 144 defaults ipykernel 5.1.0 py37h39e3cac_1002 conda-forge ipython 7.2.0 py37h39e3cac_1000 conda-forge ipython_genutils 0.2.0 py_1 conda-forge isort 4.3.4 py37_1000 conda-forge jedi 0.13.2 py37_1000 conda-forge jinja2 2.10 py_1 conda-forge jmespath 0.9.3 py_1 conda-forge jpeg 9c hfa6e2cd_1001 conda-forge jsonschema 3.0.0a3 py37_1000 conda-forge jupyter_client 5.2.4 py_1 conda-forge jupyter_core 4.4.0 py_0 conda-forge kealib 1.4.10 heacb130_1002 conda-forge keyring 18.0.0 py37_0 conda-forge kiwisolver 1.0.1 py37he980bc4_1002 conda-forge krb5 1.16.1 hc04afaa_7 defaults lazy-object-proxy 1.3.1 py37hfa6e2cd_1000 conda-forge libcurl 7.63.0 h2a8f88b_1000 defaults libffi 3.2.1 h6538335_1005 conda-forge libgdal 2.4.1 h47faea2_2 conda-forge libiconv 1.15 hfa6e2cd_1004 conda-forge libkml 1.3.0 h4fd0f3b_1009 conda-forge libnetcdf 4.6.2 h396784b_1001 conda-forge libpng 1.6.36 h7602738_1000 conda-forge libpq 11.2 h3235a2c_0 defaults libsodium 1.0.16 h2fa13f4_1001 conda-forge libspatialindex 1.8.5 he025d50_4 conda-forge libspatialite 4.3.0a h505de5d_1027 conda-forge libssh2 1.8.0 h7a1dbc1_4 defaults libtiff 4.0.10 h36446d0_1001 conda-forge libxml2 2.9.9 h464c3ec_0 defaults lzo 2.10 h6df0209_2 defaults m2w64-expat 2.1.1 2 defaults m2w64-gcc-libgfortran 5.3.0 6 defaults m2w64-gcc-libs 5.3.0 7 defaults m2w64-gcc-libs-core 5.3.0 7 defaults m2w64-gettext 0.19.7 2 defaults m2w64-gmp 6.1.0 2 defaults m2w64-libiconv 1.14 6 defaults m2w64-libwinpthread-git 5.0.0.4634.697f757 2 defaults m2w64-xz 5.2.2 2 defaults mapclassify 2.0.1 py_0 conda-forge markupsafe 1.1.0 py37hfa6e2cd_1000 conda-forge matplotlib 3.0.2 py37_1002 conda-forge matplotlib-base 3.0.2 py37h3e3dc42_1002 conda-forge mccabe 0.6.1 py_1 conda-forge mistune 0.8.4 py37hfa6e2cd_1000 conda-forge mkl 2019.1 144 defaults mkl_fft 1.0.10 py37hfa6e2cd_1 conda-forge mkl_random 1.0.2 py37h830ac7b_2 conda-forge msys2-conda-epoch 20160418 1 defaults munch 2.3.2 py_0 conda-forge nbconvert 5.4.0 py37_1 defaults nbformat 4.4.0 py_1 conda-forge networkx 2.2 py_1 conda-forge numexpr 2.6.9 py37hdce8814_0 defaults numpy 1.15.4 py37h19fb1c0_0 defaults numpy-base 1.15.4 py37hc3f5095_0 defaults numpydoc 0.8.0 py_1 conda-forge olefile 0.46 py_0 conda-forge openjpeg 2.3.1 ha922770_0 conda-forge openssl 1.1.1b hfa6e2cd_2 conda-forge packaging 19.0 py_0 conda-forge pandas 0.24.1 py37h6538335_0 conda-forge pandoc 1.19.2.1 hb2460c7_1 defaults pandocfilters 1.4.2 py_1 conda-forge parso 0.3.4 py_0 conda-forge pcre 8.42 hd6b2f15_0 defaults pickleshare 0.7.5 py37_1000 conda-forge pillow 5.4.1 py37h9a613e6_1000 conda-forge pip 19.0.2 py37_0 conda-forge poppler 0.67.0 heddaa77_6 conda-forge poppler-data 0.4.9 1 conda-forge postgresql 11.2 h3235a2c_0 defaults proj4 6.0.0 ha7a8c7b_0 conda-forge prompt_toolkit 2.0.8 py_0 conda-forge psutil 5.5.1 py37hfa6e2cd_0 conda-forge pycodestyle 2.5.0 py_0 conda-forge pycparser 2.19 py_0 conda-forge pyflakes 2.1.0 py_0 conda-forge pygments 2.3.1 py_0 conda-forge pylint 2.2.2 py37_1000 conda-forge pyopenssl 19.0.0 py37_0 conda-forge pyparsing 2.3.1 py_0 conda-forge pyproj 2.1.3 py37h2ea4b28_1 conda-forge pyqt 5.9.2 py37h6538335_2 defaults pyrsistent 0.14.10 py37hfa6e2cd_0 conda-forge pysheds 0.2.6 pypi_0 pypi pysocks 1.6.8 py37_1002 conda-forge pytables 3.5.1 py37h1da0976_0 defaults python 3.7.2 h8c8aaf0_2 defaults python-dateutil 2.8.0 py_0 conda-forge pytz 2018.9 py_0 conda-forge pywavelets 1.0.1 py37h452e1ab_1000 conda-forge pywin32-ctypes 0.2.0 py37_1000 conda-forge pyzmq 17.1.2 py37ha925a31_2 defaults qt 5.9.7 vc14h73c81de_0 defaults qtawesome 0.5.6 pyh8a2030e_0 conda-forge qtconsole 4.4.3 py_0 conda-forge qtpy 1.6.0 pyh8a2030e_0 conda-forge rasterio 1.0.22 py37hbf02ebe_1 conda-forge requests 2.21.0 py37_1000 conda-forge rope 0.11.0 py37_0 defaults rtree 0.8.3 py37h21ff451_1002 conda-forge s3transfer 0.2.0 py37_0 conda-forge scikit-image 0.14.2 py37h6538335_1 conda-forge scipy 1.2.1 py37h29ff71c_0 defaults setuptools 40.8.0 py37_0 conda-forge shapely 1.6.4 py37h222a598_0 defaults sip 4.19.8 py37h6538335_0 defaults six 1.12.0 py37_1000 conda-forge snappy 1.1.7 h777316e_3 defaults snowballstemmer 1.2.1 py_1 conda-forge snuggs 1.4.2 py37_0 defaults sphinx 1.8.4 py37_0 conda-forge sphinxcontrib-websupport 1.1.0 py_1 conda-forge spyder 3.3.3 py37_0 defaults spyder-kernels 0.4.2 py37_0 defaults sqlite 3.26.0 hfa6e2cd_1000 conda-forge testpath 0.4.2 py37_1000 conda-forge tk 8.6.9 hfa6e2cd_1000 conda-forge toolz 0.9.0 py_1 conda-forge tornado 5.1.1 py37hfa6e2cd_1000 conda-forge tqdm 4.31.1 py37_1 defaults traitlets 4.3.2 py37_1000 conda-forge urllib3 1.24.1 py37_1000 conda-forge vc 14.1 h0510ff6_4 defaults vs2015_runtime 14.15.26706 h3a45250_0 defaults wcwidth 0.1.7 py_1 conda-forge webencodings 0.5.1 py_1 conda-forge wheel 0.33.0 py37_0 conda-forge win_inet_pton 1.0.1 py37_1002 conda-forge wincertstore 0.2 py37_1002 conda-forge wrapt 1.11.1 py37hfa6e2cd_0 conda-forge xerces-c 3.2.2 h6538335_1001 conda-forge xz 5.2.4 h2fa13f4_1001 conda-forge zeromq 4.3.1 h33f27b4_3 defaults zlib 1.2.11 h2fa13f4_1004 conda-forge ```
jjhelmus commented 5 years ago

Does the issue persist if you create an environment using only packages from defaults? If so you will need to engage the conda-forge community for support.

itati01 commented 5 years ago

Thanks for the suggestion. So, I created a new environment and installed only packages from defaults. Via Anaconda Navigator I then installed Spyder. Still the same problem, though: gdal output is ok if Spyder was started from the commandline, is erroneous if Spyder was started from the start menu.

Khris777 commented 5 years ago

I have a similar problem on Windows 10.

I created a new Python 3.7.3 environment because from mpl_toolkits.basemap import Basemap wasn't working in the base environment anymore.

When I activate the new environment in the terminal and then start Spyder everything works fine, and doing

import os
print(os.environ['CONDA_DEFAULT_ENV'])

works as well.

When I use the shortcut for Spyder specifically for the new environment importing fails and the variable CONDA_DEFAULT_ENV throws a KeyError.

Anaconda Navigator Version 1.9.7

Khris777 commented 5 years ago

The issue still persists even in newly created environments, both CONDA_DEFAULT_ENV and PROJ_LIB (which basemap uses) are not available when Spyder is started using the provided shortcut.