tkrajina / srtm.py

Geo elevation data parser for "The Shuttle Radar Topography Mission" data
Apache License 2.0
245 stars 57 forks source link

Issues with Python 3 Windows 7 (x64) #10

Closed DuaneKaufman closed 8 years ago

DuaneKaufman commented 9 years ago

Hi, Does this work with Windows 7 (x64)? This installed OK, but when I try the example, I get:

c:>c:\Python34\python Python 3.4.2 (v3.4.2:ab2c023a9432, Oct 6 2014, 22:15:05) [MSC v.1600 32 bit (In tel)] on win32 Type "help", "copyright", "credits" or "license" for more information.

import srtm elevation_data = srtm.get_data() print 'CGN Airport elevation (meters):', elevation_data.get_elevation(50.8682, 7.1377) Traceback (most recent call last): File "", line 1, in File "c:\Python34\lib\site-packages\srtm\data.py", line 62, in get_elevation geo_elevation_file = self.get_file(float(latitude), float(longitude)) File "c:\Python34\lib\site-packages\srtm\data.py", line 87, in get_file data = self.retrieve_or_load_file_data(file_name) File "c:\Python34\lib\site-packages\srtm\data.py", line 99, in retrieve_or_load_file_data if self.file_handler.exists(data_file_name): File "c:\Python34\lib\site-packages\srtm\main.py", line 128, in exists return mod_path.exists('%s/%s' % (self.get_srtm_dir(), file_name)) File "c:\Python34\lib\site-packages\srtm\main.py", line 123, in get_srtm_dir mod_os.makedirs(result) File "c:\Python34\lib\os.py", line 237, in makedirs mkdir(name, mode) FileNotFoundError: [WinError 53] The network path was not found: '\/.cache/srtm'

Sincerely, Duane Kaufman

tkrajina commented 8 years ago

I just pushed a fix in 0906905979980109a2cc1d2b9974a4b47c0b610a, but I don't have any WiIndows machine to test it. Can you if it works now?

DuaneKaufman commented 8 years ago

Hello,

I downloaded the latest zip and installed it.

There is still a problem:

c:>c:\Python34\python Python 3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 20:20:57) [MSC v.1600 64 bit (AM D64)] on win32 Type "help", "copyright", "credits" or "license" for more information.

import srtm elevation_data = srtm.get_data() print('CGN Airport elevation (meters):', elevation_data.get_elevation(50.8682, 7.1377)) Traceback (most recent call last): File "", line 1, in File "c:\Python34\lib\site-packages\srtm\data.py", line 62, in get_elevation geo_elevation_file = self.get_file(float(latitude), float(longitude)) File "c:\Python34\lib\site-packages\srtm\data.py", line 87, in get_file data = self.retrieve_or_load_file_data(file_name) File "c:\Python34\lib\site-packages\srtm\data.py", line 99, in retrieve_or_loa d_file_data if self.file_handler.exists(data_file_name): File "c:\Python34\lib\site-packages\srtm\main.py", line 128, in exists return mod_path.exists('%s/%s' % (self.get_srtm_dir(), file_name)) File "c:\Python34\lib\site-packages\srtm\main.py", line 123, in get_srtm_dir mod_os.makedirs(result) File "c:\Python34\lib\os.py", line 237, in makedirs mkdir(name, mode) FileNotFoundError: [WinError 53] The network path was not found: '\.cache\srtm'

I did some snooping:

import os print(os.environ['HOME']) Traceback (most recent call last): File "", line 1, in File "c:\Python34\lib\os.py", line 635, in getitem raise KeyError(key) from None KeyError: 'HOME' print(os.environ['HOMEPATH']) \

Perhaps a better solution for this would be to use the solution given in: http://stackoverflow.com/questions/4028904/how-to-get-the-home-directory-in-python

from os.path import expanduser home = expanduser("~") print(home) C:\Users\dkaufman

Implementation of this fix seemed to fix the home user directory problem, but then I ran into this:

print('CGN Airport elevation (meters):', elevation_data.get_elevation(50.8682, 7.1377)) HOMEPATH result: C:\Users\dkaufman.cache\srtm HOMEPATH result: C:\Users\dkaufman.cache\srtm Traceback (most recent call last): File "", line 1, in File "c:\Python34\lib\site-packages\srtm\data.py", line 62, in get_elevation geo_elevation_file = self.get_file(float(latitude), float(longitude)) File "c:\Python34\lib\site-packages\srtm\data.py", line 87, in get_file data = self.retrieve_or_load_file_data(file_name) File "c:\Python34\lib\site-packages\srtm\data.py", line 132, in retrieve_or_load_file_data data = mod_utils.unzip(data) File "c:\Python34\lib\site-packages\srtm\utils.py", line 62, in unzip zip_file = mod_zipfile.ZipFile(mod_cstringio.StringIO(contents)) AttributeError: type object '_io.StringIO' has no attribute 'StringIO'

Sincerely, Duane ----- Original Message -----

From: "Tomo Krajina" notifications@github.com To: "tkrajina/srtm.py" srtm.py@noreply.github.com Cc: "DuaneKaufman" duanek@chorus.net, "Author" author@noreply.github.com Sent: Thursday, June 2, 2016 12:41:18 AM Subject: Re: [tkrajina/srtm.py] Issues with Python 3 Windows 7 (x64) (#10)

I just pushed a fix in 0906905 , but I don't have any WiIndows machine to test it. Can you if it works now?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub , or mute the thread .

tkrajina commented 8 years ago

Hey, thanks for your reply. I have an idea on how to fix it but the problem is that I have no Windows machine(s) to test with. I can only blindly make changes and ask you (or somebody else working on Windows) to test it.

Would you be interested to fix that and make a pull request? There are basically two things to solve -- having the proper separator in the path and detecting the home directory (and the solution you mentioned to me seems right).

DuaneKaufman commented 8 years ago

Hello,

I have not done a pull request before, so I am ignorant of the process.

Duane

----- Original Message -----

From: "Tomo Krajina" notifications@github.com To: "tkrajina/srtm.py" srtm.py@noreply.github.com Cc: "DuaneKaufman" duanek@chorus.net, "Author" author@noreply.github.com Sent: Sunday, June 5, 2016 1:31:33 AM Subject: Re: [tkrajina/srtm.py] Issues with Python 3 Windows 7 (x64) (#10)

Hey, thanks for your reply. I have an idea on how to fix it but the problem is that I have no Windows machine(s) to test with. I can only blindly make changes and ask you (or somebody else working on Windows) to test it.

Would you be interested to fix that and make a pull request? There are basically two things to solve -- having the proper separator in the path and detecting the home directory (and the solution you mentioned to me seems right).

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub , or mute the thread .

tkrajina commented 8 years ago

If you know how to make a git commit, everything else should be easy:

  1. Make a fork (the is a "Fork" button at the upper right part of the page).
  2. Clone your fork (or add a new remote from it and fetch, but just cloning is easier).
  3. Commit locally, test, and when ready -- push.
  4. Go to the page of your clone (the url will be https://github.com/DuaneKaufman/srtm.py) and there will be a "New pull request" button somewhere.

That's it.

DuaneKaufman commented 8 years ago

Hello,

If you know how to make a git commit, everything else should be easy:

I don't know how to do that.

Sincerely, Duane

On Jun 5, 2016, at 8:39 AM, Tomo Krajina notifications@github.com wrote:

If you know how to make a git commit, everything else should be easy:

tkrajina commented 8 years ago

Nobody interested to fix this, closing it.

vignesh1987 commented 4 years ago

Hi, This fix that you mentioned still creates the [WinError 53] The network path was not found: '/.cache/srtm'

I tried in on a windows machine and the error exists. I got this error when I was trying to work with Ridge_map (https://github.com/ColCarroll/ridge_map). Col suggested a few hacks but they surprisingly do not solve this issue