Skip to content

Commit 56e0257

Browse files
committed
Fix NotebookApp startup error on Windows
Convert all backslashes into forward slashes. This fixes the following startup exception, due to mixing forward and back slashes: ``` [E 10:34:29.657 NotebookApp] Exception while loading config file C:\Users\sftnight\.rootnb\jupyter_notebook_config.py Traceback (most recent call last): File "C:\Python38-32\lib\site-packages\traitlets\config\application.py", line 738, in _load_config_files config = loader.load_config() File "C:\Python38-32\lib\site-packages\traitlets\config\loader.py", line 614, in load_config self._read_file_as_dict() File "C:\Python38-32\lib\site-packages\traitlets\config\loader.py", line 646, in _read_file_as_dict exec(compile(f.read(), conf_filename, 'exec'), namespace, namespace) File "C:\Users\sftnight\.rootnb\jupyter_notebook_config.py", line 6 c.NotebookApp.extra_static_paths = ['C:/Users/sftnight/build/release\js\'] ```
1 parent 43c07a2 commit 56e0257

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

main/src/nbmain.cxx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,16 @@ static bool CreateJupyterConfig(string dest, string rootbin, string rootlib, str
132132
ofstream out(jupyconfig, ios::trunc);
133133
if (out.is_open()) {
134134
out << "import os" << endl;
135-
out << "rootbin = '" << rootbin << "'" << endl;
136-
out << "rootlib = '" << rootlib << "'" << endl;
137135
#ifdef WIN32
138-
string jsrootsys = rootdata + "\\js\\";
139-
out << "os.environ['PYTHONPATH'] = '%s' % rootlib + ':' + os.getenv('PYTHONPATH', '')" << endl;
140-
out << "os.environ['PATH'] = '%s:%s\\bin' % (rootbin,rootbin) + ':' + '%s' % rootlib + ':' + os.getenv('PATH', '')" << endl;
136+
std::replace( rootbin.begin(), rootbin.end(), '\\', '/');
137+
std::replace( rootdata.begin(), rootdata.end(), '\\', '/');
138+
out << "rootbin = '" << rootbin << "'" << endl;
139+
string jsrootsys = rootdata + "/js/";
140+
out << "os.environ['PYTHONPATH'] = '%s' % rootbin + ';' + os.getenv('PYTHONPATH', '')" << endl;
141+
out << "os.environ['PATH'] = '%s;%s/bin' % (rootbin,rootbin) + ';' + os.getenv('PATH', '')" << endl;
141142
#else
143+
out << "rootbin = '" << rootbin << "'" << endl;
144+
out << "rootlib = '" << rootlib << "'" << endl;
142145
string jsrootsys = rootdata + "/js/";
143146
out << "os.environ['PYTHONPATH'] = '%s' % rootlib + ':' + os.getenv('PYTHONPATH', '')" << endl;
144147
out << "os.environ['PATH'] = '%s:%s/bin' % (rootbin,rootbin) + ':' + os.getenv('PATH', '')" << endl;

0 commit comments

Comments
 (0)