Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix URLError: <urlopen error unknown url type: c> on Windows #5071

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 15, 2015
Merged

Fix URLError: <urlopen error unknown url type: c> on Windows #5071

merged 1 commit into from
Sep 15, 2015

Conversation

cgohlke
Copy link
Contributor

@cgohlke cgohlke commented Sep 15, 2015

On Windows the urlparse(...).scheme != '' test for URLs does not work. For file names the drive letter is returned as scheme:

>>> from matplotlib.externals.six.moves.urllib.parse import urlparse
>>> urlparse(r'C:\Windows\notepad.exe').scheme
'c'

Due to this issue watermark_image.py fails:

loading X:\Python35\lib\site-packages\matplotlib\mpl-data\sample_data\logo2.png
Traceback (most recent call last):
  File "watermark_image.py", line 12, in <module>
    im = image.imread(datafile)
  File "X:\Python35\lib\site-packages\matplotlib\image.py", line 1320, in imread
    fd = BytesIO(urlopen(fname).read())
  File "X:\Python35\lib\urllib\request.py", line 162, in urlopen
    return opener.open(url, data, timeout)
  File "X:\Python35\lib\urllib\request.py", line 465, in open
    response = self._open(req, data)
  File "X:\Python35\lib\urllib\request.py", line 488, in _open
    'unknown_open', req)
  File "X:\Python35\lib\urllib\request.py", line 443, in _call_chain
    result = func(*args)
  File "X:\Python35\lib\urllib\request.py", line 1310, in unknown_open
    raise URLError('unknown url type: %s' % type)
urllib.error.URLError: <urlopen error unknown url type: x>

tacaswell added a commit that referenced this pull request Sep 15, 2015
FIX: URLError: <urlopen error unknown url type: c> on Windows
@tacaswell tacaswell merged commit 38fee26 into matplotlib:master Sep 15, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants