timothydmorton / isochrones

Pythonic stellar model grid access; easy MCMC fitting of stellar properties
http://isochrones.readthedocs.org
MIT License
120 stars 61 forks source link

Python 3.5 error: module 'urllib' has no attribute 'urlretrieve' #25

Closed mrobberto closed 6 years ago

mrobberto commented 8 years ago

I am getting an error just running the first 3 lines of the example:

from isochrones.dartmouth import Dartmouth_Isochrone dar = Dartmouth_Isochrone() dar.radius(1.0, 9.7, 0.0) #M/Msun, log10(age), Fe/H Below is the error message; apparently there is an issue with urlib.retrieve. I think this module is no more available with Python3.5. Not sure how to circumvent the problem, or if a fix has to be implemented to the code. Thank you!

Downloading Dartmouth stellar model data (should happen only once)...

AttributeError Traceback (most recent call last)

in () ----> 1 from isochrones.dartmouth import Dartmouth_Isochrone 2 dar = Dartmouth_Isochrone() 3 dar.radius(1.0, 9.7, 0.0) #M/Msun, log10(age), Fe/H //anaconda/lib/python3.5/site-packages/isochrones/dartmouth.py in () 54 55 if not os.path.exists(MASTERFILE): ---> 56 _download_h5() 57 58 if not os.path.exists(TRI_FILE): //anaconda/lib/python3.5/site-packages/isochrones/dartmouth.py in _download_h5() 38 if os.path.exists(MASTERFILE): 39 os.remove(MASTERFILE) ---> 40 urllib.urlretrieve(url,MASTERFILE) 41 42 def _download_tri(): AttributeError: module 'urllib' has no attribute 'urlretrieve'
timothydmorton commented 8 years ago

Thanks for pointing this out. I have not worked to ensure Python 3 support yet; presumably there's a better Python 3-ish way to download files. Should be an easy fix.

timothydmorton commented 8 years ago

Actually, I don't know of anything other than from six.moves import urllib (which is already there), and I don't have 3.5 installed myself so am not in a position to explore. Have you tried installing isochrones by cloning the current repository (rather than using pip install isochrones)? I don't remember at what stage the from six.moves was added.

timothydmorton commented 6 years ago

This is now fixed on current master; I've improved the download function.