107107import distutils .version
108108from itertools import chain
109109
110+ import io
111+ import locale
112+ import os
113+ import re
114+ import tempfile
115+ import warnings
116+ import contextlib
117+ import distutils .sysconfig
118+
119+ # cbook must import matplotlib only within function
120+ # definitions, so it is safe to import from it here.
121+ from matplotlib .cbook import is_string_like , mplDeprecation
122+ from matplotlib .compat import subprocess
123+ from matplotlib .rcsetup import (defaultParams ,
124+ validate_backend )
125+
126+ import numpy
127+ from six .moves .urllib .request import urlopen
128+ from six .moves import reload_module as reload
129+
110130__version__ = str ('1.5.dev1' )
111131__version__numpy__ = str ('1.6' ) # minimum required numpy version
112132
@@ -164,39 +184,11 @@ def _forward_ilshift(self, other):
164184 return self
165185 pyparsing .Forward .__ilshift__ = _forward_ilshift
166186
167- try :
168- from urllib .request import urlopen
169- except ImportError :
170- from urllib2 import urlopen
171-
172- import io
173- import locale
174- import os
175- import re
176- import tempfile
177- import warnings
178- import contextlib
179- import distutils .sysconfig
180-
181- # cbook must import matplotlib only within function
182- # definitions, so it is safe to import from it here.
183- from matplotlib .cbook import is_string_like , mplDeprecation
184- from matplotlib .compat import subprocess
185-
186- try :
187- reload
188- except NameError :
189- # Python 3
190- from imp import reload
191-
192187
193188if not hasattr (sys , 'argv' ): # for modpython
194189 sys .argv = [str ('modpython' )]
195190
196191
197- from matplotlib .rcsetup import (defaultParams ,
198- validate_backend )
199-
200192major , minor1 , minor2 , s , tmp = sys .version_info
201193_python24 = (major == 2 and minor1 >= 4 ) or major >= 3
202194
@@ -208,7 +200,6 @@ def _forward_ilshift(self, other):
208200 raise ImportError ('matplotlib requires Python 2.4 or later' )
209201
210202
211- import numpy
212203if not compare_versions (numpy .__version__ , __version__numpy__ ):
213204 raise ImportError (
214205 'numpy %s or later is required; you have %s' % (
@@ -1125,7 +1116,6 @@ def rc_params_from_file(fname, fail_on_error=False, use_default_template=True):
11251116rcParams ['text.usetex' ] = checkdep_usetex (rcParams ['text.usetex' ])
11261117
11271118if rcParams ['axes.formatter.use_locale' ]:
1128- import locale
11291119 locale .setlocale (locale .LC_ALL , '' )
11301120
11311121
0 commit comments