Skip to content

Commit 6b49547

Browse files
committed
Update pvsystem.py
1 parent e3d77b5 commit 6b49547

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

pvlib/pvsystem.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -551,10 +551,17 @@ def retrieve_sam(name=None, samfile=None):
551551
response = urlopen(url)
552552
csvdata = io.StringIO(response.read().decode(errors='ignore'))
553553
elif samfile == 'select':
554-
import tkinter
555-
from tkinter.filedialog import askopenfilename
556-
tkinter.Tk().withdraw()
557-
csvdata = askopenfilename()
554+
try:
555+
# python 2
556+
import Tkinter as tkinter
557+
from tkFileDialog import askopenfilename
558+
except ImportError:
559+
# python 3
560+
import tkinter
561+
from tkinter.filedialog import askopenfilename
562+
563+
tkinter.Tk().withdraw()
564+
csvdata = askopenfilename()
558565
else:
559566
csvdata = samfile
560567

0 commit comments

Comments
 (0)