Skip to content
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

nbconvert: Default encoding problem on OS X #4562

Closed
spacecataz opened this issue Nov 20, 2013 · 2 comments · Fixed by #4563
Closed

nbconvert: Default encoding problem on OS X #4562

spacecataz opened this issue Nov 20, 2013 · 2 comments · Fixed by #4563
Milestone

Comments

@spacecataz
Copy link

Greetings.

I am using IPython 1.1.0 via MacPorts on OSX 10.7.5. The following problem is reproducible on the master git branch (IPython 2.0.0-dev).

On any call to nbconvert, I get the following failure:

[NbConvertApp] Using existing profile dir: u'/Users/USERNAME_REDACTED/.ipython/profile_default'
[NbConvertApp] Converting notebook ticks.ipynb to html
[NbConvertApp] Support files will be in ticks_files/
Traceback (most recent call last):
  File "/opt/local/bin/ipython", line 6, in <module>
    start_ipython()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/IPython/__init__.py", line 118, in start_ipython
    return launch_new_instance(argv=argv, **kwargs)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/IPython/config/application.py", line 545, in launch_instance
    app.start()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/IPython/terminal/ipapp.py", line 358, in start
    return self.subapp.start()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/IPython/nbconvert/nbconvertapp.py", line 267, in start
    self.convert_notebooks()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/IPython/nbconvert/nbconvertapp.py", line 300, in convert_notebooks
    output, resources = exporter.from_filename(notebook_filename, resources=resources)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/IPython/nbconvert/exporters/exporter.py", line 288, in from_filename
    with io.open(filename) as f:
LookupError: unknown encoding: 

If you suspect this is an IPython bug, please report it at:
    https://github.com/ipython/ipython/issues
or send an email to the mailing list at ipython-dev@scipy.org

You can print a more detailed traceback right now with "%tb", or use "%debug"
to interactively debug it.

Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
    c.Application.verbose_crash=True

This is an easy fix: I change the troublesome line such that it reads,

with io.open(filename, encoding='ascii') as f:

However, this ad hoc and likely a suboptimal solution. I wanted to bring this to the developers' attention and inquire about a proper solution. Thanks!

System info:

python -c "import IPython; print(IPython.sys_info())"
{'codename': 'An Afternoon Hack',
 'commit_hash': '7c2ea3a',
 'commit_source': 'installation',
 'default_encoding': 'US-ASCII',
 'ipython_path': '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/IPython',
 'ipython_version': '1.1.0',
 'os_name': 'posix',
 'platform': 'Darwin-11.4.2-x86_64-i386-64bit',
 'sys_executable': '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python',
 'sys_platform': 'darwin',
 'sys_version': '2.7.6 (default, Nov 19 2013, 16:37:14) \n[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)]'}
@takluyver
Copy link
Member

I hate the fact that io.open has an environment-dependent default, it's so easy for things like this to get overlooked. PR coming up.

That said, you're using a modern Mac - why on earth is the default encoding anything other than UTF-8? 😕

@minrk
Copy link
Member

minrk commented Nov 20, 2013

It could be macports, which does all kinds of unfortunate things.

@spacecataz what terminal are you using, and what are locale.getpreferredencoding() and env | grep LANG and env | grep LC?

mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this issue Nov 3, 2014
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 a pull request may close this issue.

3 participants