-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Can't import pyplot in matplotlib 2.0 rc2 #7715
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
Comments
How exactly did you install 2.0.0rc2? What is the output of Can you try with python3? |
I provided the exact command I used in the beginning. Using the command you wrote didn't update my existing installation (maybe I should have added --upgrade there too?). I can't try with python3 right away, can report later. There are non-ascii file names in the system, but previous versions worked fine.
|
And I am having problems getting mpl to work on my python3 installation, not sure I am very keen on figuring it out today. |
Ah, I was confused by a linebreak 🐑 . What is your default system encoding?
Digging in a bit more, this is not issues with things blowing up when the list comes back, but something is subprocess32 choking when searching for the binary. Do you have a 'Ð' in your path someplace? Exceprting from subprocess32 def _get_exec_path(env=None):
"""Returns the sequence of directories that will be searched for the
named executable (similar to a shell) when launching a process.
*env* must be an environment variable dict or None. If *env* is None,
os.environ will be used.
"""
if env is None:
env = os.environ
return env.get('PATH', os.defpath).split(os.pathsep) and # This matches the behavior of os._execvpe().
path_list = _get_exec_path(env)
executable_list = (os.path.join(dir, executable)
for dir in path_list)
|
Default encoding is UTF8, standard Ubuntu. Or are you asking something else? |
I got that glyph by guessing encoding as that byte is not valid utf-8 but latin-1 worked. Can you try: import subprocess32 as subprocess
subprocess.check_output(['ls']) and out = subprocess.check_output(['fc-list', '--format=%{file}']) |
|
I am truely stumped, that is the line that is raising in the OP? Can you try walking back via |
I have never used %debug, so let me know if I should do something else with it.
|
That directory is likely still in your I still don't understand why you get this failure when importing matplotlib and not when just running the |
OK, whatever the reason for that was, I removed all non-ascii paths from the |
It is because we modernized how we did this external process call to use I am failing to quickly find any bug-reports upstream about this. |
I explicitly added
|
Could it have something to do with the language of the system? Mine is set to Russian. |
What is the output of |
|
I can reproduce this.
Note that this is because |
Actually the stdlib And note that in theory this probably could affect any use of |
🤦♂️ That makes perfect sense in retrospect. The simplest solution is to just wrap |
I guess |
but in python3 doesn't it need to be a unicode object (as it will be added to unicode literals later)? |
IIRC py3 handles bytes just fine because the code path is different. |
Other than the Powell metric of code quality [1], is there any reason to prefer [1] "Good code is code I wrote, bad code is code you wrote." James Powell around minute 20 |
I think |
Closes matplotlib#7715 This ensures that on python2 the values passed into `check_output` are bytes. If they are passed in as unicode (due to unicode_literals at the top of most of our files) they will cause an exception when there is a path in PATH that has non-ascii values. The reason is that when locating possible executable our input (as unicode) is concatenated with the non-ascii path (as bytes) which then fails to encode as ascii and raises. The other two places we currently use `check_output` (setupext.py and tools/github_stats.py) we do not need this handling as we do not import unicode_iterals in those files.
@Phlya Thanks for bearing with us while getting this sorted out! |
Closes matplotlib#7715 This ensures that on python2 the values passed into `check_output` or `Popen` are bytes. If they are passed in as unicode (due to unicode_literals at the top of most of our files) they will cause an exception when there is a path in PATH that has non-ascii values. The reason is that when locating possible executable our input (as unicode) is concatenated with the non-ascii path (as bytes) which then fails to encode as ascii and raises. The other two places we currently use `check_output` (setupext.py and tools/github_stats.py) we do not need this handling as we do not import unicode_iterals in those files.
closed by #7804 |
Great, thank you! Glad I could help. |
I have just upgraded to 2.0 rc2 on Ubuntu 14.04 using
sudo pip install https://github.com/matplotlib/matplotlib/archive/v2.0.0rc2.zip
(from 1.5.3, which I got using pip from pypi). After the upgrade I can import matplotlib, but not pyplot:Please let me know if you need any more details.
The text was updated successfully, but these errors were encountered: