Eugene
Eugene

Reputation: 263

Ipython notebook cannot start up (Windows 8.1)

I'm using a Japanese version of windows 8.1 installed on my computer. The problem is that my windows is in japanese as such I'm not able to use ipython to open up .pynb files...Do anyone have similar issues? I will appreciate all help provided. Thank you.

The error message is as shown below. [C 23:46:56.016 NotebookApp] Bad config encountered during initialization: [C 23:46:56.016 NotebookApp] Could not decode 'C:\Users\x83\x86\x81[\x83W\x81 [\x83\x93.jupyter' for unicode trait 'config_dir' of a NotebookApp instance.

Upvotes: 1

Views: 2332

Answers (3)

YO_N
YO_N

Reputation: 41

It can be solved in file .\Lib\site-packages\jupyter_core\paths.py where you can find a function get_home_dir().

Write an absolute path to your homedir, for example by default you have:

homedir = os.path.expanduser('~')

and it could be changed to this one:

homedir = os.path.abspath('yourpath')

your absolute path to the folder, for example C:\Anaconda2\Notebooks.

However, this problem only for those, who are using Python 2.7.

Upvotes: 0

mugiseyebrows
mugiseyebrows

Reputation: 4743

Python 2.7 have issues with non-ascii environment variable values. Jypyter uses environment variables to get "home" and "appdata" directories. Good thing Jypyter have it's own environment variables to override defaults (you can check it in C:\Python27\Lib\site-packages\jupyter_core\paths.py and C:\Python27\Lib\site-packages\jupyter_core\migrate.py): JUPYTER_CONFIG_DIR, JUPYTER_DATA_DIR, JUPYTER_RUNTIME_DIR,IPYTHONDIR. You need to set them to existing non-unicode destinations. Create symlink to C:\users\.ipython in C:\data run mklink /J C:\data\.ipython "%USERPROFILE%\.ipython" in console. I wrote script for that (C:\data must exist (assuming you have Python 2.7 and it is in C:\Python27)). I run this script instead of ipython notebook. (You also need to create symlink to C:\users\.ipython in C:\data, run mklink /J C:\data\.ipython "%USERPROFILE%\.ipython" in console (cmd.exe))

import os
import subprocess

base = 'C:\\data'
jupyter_dir = os.path.join(base,'.jupyter')
if not os.path.exists(jupyter_dir):
  os.mkdir(jupyter_dir)

dirs = {'JUPYTER_CONFIG_DIR' : jupyter_dir, 'JUPYTER_RUNTIME_DIR' : os.path.join(jupyter_dir,'runtime'),'JUPYTER_DATA_DIR' : os.path.join(jupyter_dir,'data')}

for k,v in dirs.iteritems():
  if not os.path.exists(v):
    os.mkdir(v)
  os.environ[k] = v

ipython_dir = os.path.join(base,'.ipython')

os.environ['IPYTHONDIR'] = ipython_dir

subprocess.call(['C:\\Python27\\Scripts\\jupyter-notebook.exe'])

I know, butchering directory tree is not elegant solution, but it works.

Upvotes: 2

Kenneth Han
Kenneth Han

Reputation: 37

It may be solved, if you are using alphabet character on your user name rather than your own language (kanji).

I also search answer using ipython notebook by not to change my user name...

Upvotes: 0

Related Questions