URLError: <urlopen error [errno 11002] getaddrinfo 失败>



'亲爱的所有人,当我试图运行PyPSA示例时,我得到下面显示的错误消息。我用我的个人笔记本电脑和笔记本电脑在合作设置后尝试了这个问题,得到了同样的错误。两台笔记本电脑都显示"代理设置为关闭"。我也运行过DNS刷新,但运气不好。如有任何帮助,我将不胜感激。

"

import pypsa
import numpy as np
import pandas as pd
import os
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
%matplotlib inline
plt.rc('figure', figsize=(8,8))
network = pypsa.examples.ac_dc_meshed(from_master=True)
#get current type (AC or DC) of the lines from the buses
lines_current_type = network.lines.bus0.map(network.buses.carrier)
lines_current_type
network.plot(line_colors=lines_current_type.map(lambda ct: "r" if ct=="DC" else "b"),
title='Mixed AC (blue) - DC (red) network - DC (cyan)',
color_geomap=True, jitter=.3)
plt.tight_layout()

"

'---------------------------------------------------------------------------
gaierror                                  Traceback (most recent call last)
~Anaconda3liburllibrequest.py in do_open(self, http_class, req, **http_conn_args)
1318                 h.request(req.get_method(), req.selector, req.data, headers,
-> 1319                           encode_chunked=req.has_header('Transfer-encoding'))
1320             except OSError as err: # timeout error
~Anaconda3libhttpclient.py in request(self, method, url, body, headers, encode_chunked)
1251         """Send a complete request to the server."""
-> 1252         self._send_request(method, url, body, headers, encode_chunked)
1253 
~Anaconda3libhttpclient.py in _send_request(self, method, url, body, headers, encode_chunked)
1297             body = _encode(body, 'body')
-> 1298         self.endheaders(body, encode_chunked=encode_chunked)
1299 
~Anaconda3libhttpclient.py in endheaders(self, message_body, encode_chunked)
1246             raise CannotSendHeader()
-> 1247         self._send_output(message_body, encode_chunked=encode_chunked)
1248 
~Anaconda3libhttpclient.py in _send_output(self, message_body, encode_chunked)
1025         del self._buffer[:]
-> 1026         self.send(msg)
1027 
~Anaconda3libhttpclient.py in send(self, data)
965             if self.auto_open:
--> 966                 self.connect()
967             else:
~Anaconda3libhttpclient.py in connect(self)
1413 
-> 1414             super().connect()
1415 
~Anaconda3libhttpclient.py in connect(self)
937         self.sock = self._create_connection(
--> 938             (self.host,self.port), self.timeout, self.source_address)
939         self.sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
~Anaconda3libsocket.py in create_connection(address, timeout, source_address)
706     err = None
--> 707     for res in getaddrinfo(host, port, 0, SOCK_STREAM):
708         af, socktype, proto, canonname, sa = res
~Anaconda3libsocket.py in getaddrinfo(host, port, family, type, proto, flags)
751     addrlist = []
--> 752     for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
753         af, socktype, proto, canonname, sa = res
gaierror: [Errno 11002] getaddrinfo failed
During handling of the above exception, another exception occurred:
URLError                                  Traceback (most recent call last)
~Anaconda3libsite-packagesIPythoncoreformatters.py in __call__(self, obj)
339                 pass
340             else:
--> 341                 return printer(obj)
342             # Finally look for special method names
343             method = get_real_method(obj, self.print_method)
~Anaconda3libsite-packagesIPythoncorepylabtools.py in <lambda>(fig)
246 
247     if 'png' in formats:
--> 248         png_formatter.for_type(Figure, lambda fig: print_figure(fig, 'png', **kwargs))
249     if 'retina' in formats or 'png2x' in formats:
250         png_formatter.for_type(Figure, lambda fig: retina_figure(fig, **kwargs))
~Anaconda3libsite-packagesIPythoncorepylabtools.py in print_figure(fig, fmt, bbox_inches, **kwargs)
130         FigureCanvasBase(fig)
131 
--> 132     fig.canvas.print_figure(bytes_io, **kw)
133     data = bytes_io.getvalue()
134     if fmt == 'svg':
~Anaconda3libsite-packagesmatplotlibbackend_bases.py in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, **kwargs)
2063                         orientation=orientation,
2064                         dryrun=True,
-> 2065                         **kwargs)
2066                     renderer = self.figure._cachedRenderer
2067                     bbox_artists = kwargs.pop("bbox_extra_artists", None)
~Anaconda3libsite-packagesmatplotlibbackendsbackend_agg.py in print_png(self, filename_or_obj, metadata, pil_kwargs, *args, **kwargs)
525 
526         else:
--> 527             FigureCanvasAgg.draw(self)
528             renderer = self.get_renderer()
529             with cbook._setattr_cm(renderer, dpi=self.figure.dpi), 
~Anaconda3libsite-packagesmatplotlibbackendsbackend_agg.py in draw(self)
386         self.renderer = self.get_renderer(cleared=True)
387         with RendererAgg.lock:
--> 388             self.figure.draw(self.renderer)
389             # A GUI class may be need to update a window using this draw, so
390             # don't forget to call the superclass.
~Anaconda3libsite-packagesmatplotlibartist.py in draw_wrapper(artist, renderer, *args, **kwargs)
36                 renderer.start_filter()
37 
---> 38             return draw(artist, renderer, *args, **kwargs)
39         finally:
40             if artist.get_agg_filter() is not None:
~Anaconda3libsite-packagesmatplotlibfigure.py in draw(self, renderer)
1707             self.patch.draw(renderer)
1708             mimage._draw_list_compositing_images(
-> 1709                 renderer, self, artists, self.suppressComposite)
1710 
1711             renderer.close_group('figure')
~Anaconda3libsite-packagesmatplotlibimage.py in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
133     if not_composite or not has_images:
134         for a in artists:
--> 135             a.draw(renderer)
136     else:
137         # Composite any adjacent images together
~Anaconda3libsite-packagesmatplotlibartist.py in draw_wrapper(artist, renderer, *args, **kwargs)
36                 renderer.start_filter()
37 
---> 38             return draw(artist, renderer, *args, **kwargs)
39         finally:
40             if artist.get_agg_filter() is not None:
~Anaconda3libsite-packagescartopymplgeoaxes.py in draw(self, renderer, **kwargs)
477         self._done_img_factory = True
478 
--> 479         return matplotlib.axes.Axes.draw(self, renderer=renderer, **kwargs)
480 
481     def _update_title_position(self, renderer):
~Anaconda3libsite-packagesmatplotlibartist.py in draw_wrapper(artist, renderer, *args, **kwargs)
36                 renderer.start_filter()
37 
---> 38             return draw(artist, renderer, *args, **kwargs)
39         finally:
40             if artist.get_agg_filter() is not None:
~Anaconda3libsite-packagesmatplotlibaxes_base.py in draw(self, renderer, inframe)
2645             renderer.stop_rasterizing()
2646 
-> 2647         mimage._draw_list_compositing_images(renderer, self, artists)
2648 
2649         renderer.close_group('axes')
~Anaconda3libsite-packagesmatplotlibimage.py in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
133     if not_composite or not has_images:
134         for a in artists:
--> 135             a.draw(renderer)
136     else:
137         # Composite any adjacent images together
~Anaconda3libsite-packagesmatplotlibartist.py in draw_wrapper(artist, renderer, *args, **kwargs)
36                 renderer.start_filter()
37 
---> 38             return draw(artist, renderer, *args, **kwargs)
39         finally:
40             if artist.get_agg_filter() is not None:
~Anaconda3libsite-packagescartopymplfeature_artist.py in draw(self, renderer, *args, **kwargs)
153         except ValueError:
154             warnings.warn('Unable to determine extent. Defaulting to global.')
--> 155         geoms = self._feature.intersecting_geometries(extent)
156 
157         # Combine all the keyword args in priority order.
~Anaconda3libsite-packagescartopyfeature__init__.py in intersecting_geometries(self, extent)
300         """
301         self.scaler.scale_from_extent(extent)
--> 302         return super(NaturalEarthFeature, self).intersecting_geometries(extent)
303 
304     def with_scale(self, new_scale):
~Anaconda3libsite-packagescartopyfeature__init__.py in intersecting_geometries(self, extent)
108             extent_geom = sgeom.box(extent[0], extent[2],
109                                     extent[1], extent[3])
--> 110             return (geom for geom in self.geometries() if
111                     geom is not None and extent_geom.intersects(geom))
112         else:
~Anaconda3libsite-packagescartopyfeature__init__.py in geometries(self)
284             path = shapereader.natural_earth(resolution=self.scale,
285                                              category=self.category,
--> 286                                              name=self.name)
287             geometries = tuple(shapereader.Reader(path).geometries())
288             _NATURAL_EARTH_GEOM_CACHE[key] = geometries
~Anaconda3libsite-packagescartopyioshapereader.py in natural_earth(resolution, category, name)
293     format_dict = {'config': config, 'category': category,
294                    'name': name, 'resolution': resolution}
--> 295     return ne_downloader.path(format_dict)
296 
297 
~Anaconda3libsite-packagescartopyio__init__.py in path(self, format_dict)
220         else:
221             # we need to download the file
--> 222             result_path = self.acquire_resource(target_path, format_dict)
223 
224         return result_path
~Anaconda3libsite-packagescartopyioshapereader.py in acquire_resource(self, target_path, format_dict)
348         url = self.url(format_dict)
349 
--> 350         shapefile_online = self._urlopen(url)
351 
352         zfh = ZipFile(six.BytesIO(shapefile_online.read()), 'r')
~Anaconda3libsite-packagescartopyio__init__.py in _urlopen(self, url)
259         """
260         warnings.warn('Downloading: {}'.format(url), DownloadWarning)
--> 261         return urlopen(url)
262 
263     @staticmethod
~Anaconda3liburllibrequest.py in urlopen(url, data, timeout, cafile, capath, cadefault, context)
220     else:
221         opener = _opener
--> 222     return opener.open(url, data, timeout)
223 
224 def install_opener(opener):
~Anaconda3liburllibrequest.py in open(self, fullurl, data, timeout)
523             req = meth(req)
524 
--> 525         response = self._open(req, data)
526 
527         # post-process response
~Anaconda3liburllibrequest.py in _open(self, req, data)
541         protocol = req.type
542         result = self._call_chain(self.handle_open, protocol, protocol +
--> 543                                   '_open', req)
544         if result:
545             return result
~Anaconda3liburllibrequest.py in _call_chain(self, chain, kind, meth_name, *args)
501         for handler in handlers:
502             func = getattr(handler, meth_name)
--> 503             result = func(*args)
504             if result is not None:
505                 return result
~Anaconda3liburllibrequest.py in https_open(self, req)
1360         def https_open(self, req):
1361             return self.do_open(http.client.HTTPSConnection, req,
-> 1362                 context=self._context, check_hostname=self._check_hostname)
1363 
1364         https_request = AbstractHTTPHandler.do_request_
~Anaconda3liburllibrequest.py in do_open(self, http_class, req, **http_conn_args)
1319                           encode_chunked=req.has_header('Transfer-encoding'))
1320             except OSError as err: # timeout error
-> 1321                 raise URLError(err)
1322             r = h.getresponse()
1323         except:
URLError: <urlopen error [Errno 11002] getaddrinfo failed>
<Figure size 576x576 with 1 Axes>'

错误消失与IT团队讨论后与公司的笔记本电脑和禁用一些安全设置。对于人员问题,它在刷新DNS后消失了,但不确定究竟是什么解决了这个问题。

最新更新