Problem with loading text files JupyterLab in python


initially I had problems with 5% of my students not being able to get a stable kernel their anaconda installation. So I moved those students to JupyterLab.

How is it possible in JupyterLab to read in a Text file, e.g. with Numpy np.loadtxt(). I was suprized that it did not work. I did upload the file in the main directory. It returned

OSError: data.txt not found.

Many thanks in advance.


You’d have to specify what version of JupyterLab and what version of Numpy.
This isn’t my experience:

Works with:

  • JupyterLab Version 3.2.8
  • Numpy version 1.21.5

Or works with:

  • JupyterLab Version 3.3.0rc0
  • Numpy version 1.21.6

Or works with:

  • JupyterLab Version 3.3.2
  • Numpy version 1.21.6

Click the launch badge below to try it with the notebook that comes up upon launch in 3.25 with 1.21.5 (presently):


I am using Jupyter lap from here: JupyterLite

and the numpy version there is: ‘1.21.4’

import numpy as np


import numpy as np


OSError Traceback (most recent call last)
Input In [5], in <cell line: 1>()
----> 1 np.loadtxt(‘data.txt’)

File /lib/python3.9/site-packages/numpy/lib/, in loadtxt(fname, dtype, comments, delimiter, converters, skiprows, usecols, unpack, ndmin, encoding, max_rows, like)
1065 fname = os_fspath(fname)
1066 if _is_string_like(fname):
→ 1067 fh =, ‘rt’, encoding=encoding)
1068 fencoding = getattr(fh, ‘encoding’, ‘latin1’)
1069 fh = iter(fh)

File /lib/python3.9/site-packages/numpy/lib/, in open(path, mode, destpath, encoding, newline)
156 “”"
157 Open path with mode and return the file object.
190 “”"
192 ds = DataSource(destpath)
→ 193 return, mode, encoding=encoding, newline=newline)

File /lib/python3.9/site-packages/numpy/lib/, in, path, mode, encoding, newline)
530 return _file_openers[ext](found, mode=mode,
531 encoding=encoding, newline=newline)
532 else:
→ 533 raise IOError("%s not found." % path)

OSError: data.txt not found.

f = open(‘data.txt’, ‘r’)

FileNotFoundError Traceback (most recent call last)
Input In [6], in <cell line: 1>()
----> 1 f = open(‘data.txt’, ‘r’)

FileNotFoundError: [Errno 44] No such file or directory: ‘data.txt’

There’s big warning indicating JupyterLab launches are experimental when you go to Try Jupyter page. You can read more about the impetus behind this here. You’ve stumbled upon something odd about it. (See my second part below.)

In general, you want to use JupyterLab running a full Python kernel for the best experience right now, especially for teaching.

Launch JupyteLab with a full Python kernel available from the MyBinder JupyterLab demo page.


Interestingly, my test code/notebook works? If you skip the %pip install and run the rest.

It is very strange. So for some reason, the file made by the %store magic is saved but doesn’t show in the JupyterLite file navigator??? Yet, numpy can see the text file and load it. Yet, if you make a text file via the launcher in JupyterLite, numpy cannot see it even though it shows in the file navigator.

So technically, np.loadtxt() works on JupyterLite; however, there is something odd about the files you see in the file navigator (or add that by dragging in or make using the launcher in JupyterLite) and what numpy sees. The flipside is the text file I made with %store doesn’t show up; yet can be used by np.loadtxt().

This comment looks pertinent to this issue from issue ‘File not found, but clearly uploaded. Openpyxl cannot be installed?’:

“- at present, files uploaded to your browser are not trivially available in the kernel” SOURCE: Comment by Nicholas (@bollwyvl)

Thank you, great, this will help the 5% of the students which did not manage to get the installation done.

Do you have one idea why the installation for some windows user did not work. The session is remotely so I can not check their computers. Some of them could not establish a kernel.

Ideas in no particular order:

  • Windows 11 is now running around?
  • Some people don’t put on the WSL and some do.
  • Some users have OneDrive handling way more than they realize.
  • Some people have older installations of some things while others don’t.

I imagine it would be hard to track what the main issue among that 5% is, unless in person.

Exactly, this is why I moved them to binder. Thanks this already helped me a lot.

Yes, sorry you weren’t aware about the switch to JupyterLite and the cutting edge nature of it. However, I should add that any launch from MyBinder also has JupyterLab available, in case you didn’t know that and are trying to use JupyterLab to keep the interface standard. Usually you can press the Jupyter logo on the upper left even when launches are from the classic notebook interface. That may be important because you may want to use other options for the environment in launched sessions for the students not working local.

There’s ways to switch using the URL, too, but that’s a heavy ask of novices.

It’s also possible to edit a copy of any launch binder URL to have it go to JupyterLab directly if you like even if the one offered at the site is set to go to the classic notebook interface.

1 Like