# Not reading file after opening console / Variable explorer

**URL:** <https://discourse.jupyter.org/t/not-reading-file-after-opening-console-variable-explorer/23875>\
**Category:** Notebook\
**Created:** [February 9, 2024, 12:46pm UTC](https://discourse.jupyter.org/t/not-reading-file-after-opening-console-variable-explorer/23875 "2024-02-09T12:46:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Drooembueddel](https://avatars.discourse-cdn.com/v4/letter/d/f07891/32.png) [@Drooembueddel](https://discourse.jupyter.org/u/Drooembueddel)\
**Post date:** [February 9, 2024, 12:46pm UTC](https://discourse.jupyter.org/t/not-reading-file-after-opening-console-variable-explorer/23875/1 "2024-02-09T12:46:28Z")

</div>

Hey,  
I’m using Python 3.9.18, Jupyter Notebook 7.0.6 in Spyder 5.5.0 (set up through anaconda) on Linux Mint 21.1 Cinnamon.

Whenever I want to read a file using `glob` and `os (posix)` while I have a Console open (because I would like to use the variable explorer) I loose the ability to read a file from my drive (Code see below). When I restart the kernel and I run the code without opening a console, it works just fine. If I then start a console and run the import-cell again, the problem is back. Can anybody reproduce this or is there something not working in my setup?

Code to reproduce:  
Cell 1

> import geopandas as gpd  
> import glob  
> import os

Cell 2

> path = ‘…/FOLDER/\*.gpkg’ #\<-- this needs to point to a folder with gpkg-file on local drive  
> files = glob.glob(path)  
> read\_file = max(files, key=os.path.getctime)  
> read\_file

Optional Cell 3

> gdf=gpd.read\_file(read\_file)

The error it throws is

> Traceback (most recent call last):  
> Cell In[6], line 3  
> read\_file = max(files, key=os.path.getctime)  
> ValueError: max() arg is an empty sequence

because `files` will be empty…

I’ve kind of accepted it for now, but if others have the same issue this could maybe go on github to be fixed in the future?

---

<div class="post-metadata">

**Author:** ![fomightez](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/fomightez/32/495_2.png) [@fomightez](https://discourse.jupyter.org/u/fomightez)\
**Post date:** [February 9, 2024, 4:11pm UTC](https://discourse.jupyter.org/t/not-reading-file-after-opening-console-variable-explorer/23875/2 "2024-02-09T16:11:17Z")

</div>

> [@Drooembueddel](#):
>
> If I then start a console and run the import-cell again, the problem is back.

Just so I’m following fully, can you clarify you are opening the console at that point after you restart the kernel by right-clicking and choosing ‘`New Console for Notebook`’?

> [@Drooembueddel](#):
>
> path = ‘…/FOLDER/\*.gpkg’ #\<-- this needs to point to a folder with gpkg-file on local drive

Is that path an absolute or relative path? Have you tried changing to whatever it isn’t and see if ti changes things?

> [@Drooembueddel](#):
>
> Can anybody reproduce this

You can test some of the universality of this yourself, perhaps. I’ve tried so far sort of (I didn’t bother involving geopandas) with 7.1.0 and I’m not seeing it but maybe I’m not understanding as of yet.

You can try Jupyter Notebook 7.1.0 by going [here](https://gist.github.com/jtpio/83b0b625cb3b6e05d7f3d8714f98182e) and clicking ‘launch binder’.

You can try Jupyter Notebook version 7.0.4 by going [here](https://gist.github.com/jtpio/35a72862c8be13dee31b61ebac2d9786) and clicking ‘launch binder’.  
Unfortunately, I am not seeing 7.0.6 but you could copy the gist and make one with that version.

---

<div class="post-metadata">

**Author:** ![Drooembueddel](https://avatars.discourse-cdn.com/v4/letter/d/f07891/32.png) [@Drooembueddel](https://discourse.jupyter.org/u/Drooembueddel)\
**Post date:** [February 9, 2024, 4:35pm UTC](https://discourse.jupyter.org/t/not-reading-file-after-opening-console-variable-explorer/23875/3 "2024-02-09T16:35:35Z")

</div>

Just to clarify: I’m using the notebook as a Spyder-Add-On. I think that has a lot to do with it! Am I even in the right forum here? That’s where I got following the link from inside my Spyder-notebook to github and then to here… 🤔

To your questions:  
It doesn’t matter when exactly I open the console. If it is open, it won’t work.

I start the console using the menu like so:  
 ![grafik](https://canada1.discourse-cdn.com/flex031/uploads/jupyter/original/2X/7/73b7b509bddb88ae5a6ab1ab96d04ccf2b3526dd.png)

The code is a relative one (there should only be two points at the beginning 🙈). If I use an absolute path it works!

Using binder brings the error message even with the absolute path and without a console - but I think that’s because my path isn’t correct in relation to wherever binder executes the software 😟

---

<div class="post-metadata">

**Author:** ![fomightez](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/fomightez/32/495_2.png) [@fomightez](https://discourse.jupyter.org/u/fomightez)\
**Post date:** [February 9, 2024, 5:33pm UTC](https://discourse.jupyter.org/t/not-reading-file-after-opening-console-variable-explorer/23875/4 "2024-02-09T17:33:40Z")

</div>

> [@Drooembueddel](#):
>
> The code is a relative one (there should only be two points at the beginning 🙈). If I use an absolute path it works!

The absolute path working vs. relative is interesting.

> [@Drooembueddel](#):
>
> Using binder brings the error message even with the absolute path and without a console - but I think that’s because my path isn’t correct in relation to wherever binder executes the software

Hmmm…if it happens in MyBinder then the issue would belong here in this forum; however, I cannot still tell if that is the case. For the path in my test I used `path = ‘.'` so it would be where I was making notebooks. I didn’t notice any issue but if you want to use `.gpkg` stuff that may be different. And it also may mean it is very edge case.

---

<div class="post-metadata">

**Author:** ![Drooembueddel](https://avatars.discourse-cdn.com/v4/letter/d/f07891/32.png) [@Drooembueddel](https://discourse.jupyter.org/u/Drooembueddel)\
**Post date:** [February 10, 2024, 12:31pm UTC](https://discourse.jupyter.org/t/not-reading-file-after-opening-console-variable-explorer/23875/5 "2024-02-10T12:31:13Z")

</div>

I’d expect it has nothing to do with using gpkg, I have the problem even when I don’t import geopandas.

I don’t get MyBinder to work - specifically: I couldn’t figure out where I need to have things on my local drive in order for it to find stuff 😬 I even created a new file, saved it and then did a search for the name - but I couldn’t find it. It doesn’t help that Binder doesn’t have a normal file-open dialog (can’t think of the right term right now)… Also don’t really have time right now to do more testing ☹

And as I said: I wouldn’t be surprised if the problem lies in the combination of notebook and spyder.

---

<div class="post-metadata">

**Author:** ![fomightez](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/fomightez/32/495_2.png) [@fomightez](https://discourse.jupyter.org/u/fomightez)\
**Post date:** [February 10, 2024, 2:35pm UTC](https://discourse.jupyter.org/t/not-reading-file-after-opening-console-variable-explorer/23875/6 "2024-02-10T14:35:41Z")

</div>

MyBinder runs on a remote computer. It’s like JupyterHub. You upload your local files to the remote system for it to be able to use them.

For Jupyter Notebook, you initiate upload in the Jupyter Dashboard. When you first click on the Notebook 7.1 link I sent you it start out in the Jupyter Dashboard. There’s an ‘`Upload`’ button in the upper right side.

In JupyterLab, initiating the upload is as easy as drag-and-drop into the file browser panel on the left side of the JupyterLab interface. That’s why a lot of users prefer the more feature-rich interface.
