question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Directory recognition problem

See original GitHub issue

Hello guys, I’m not sure if it’s a mistake or if I’m doing something wrong. Can anybody help me?

The function below works well on the console. But when I try to print using PyScript and the Live Server extension, I get the following error:

with open(r"C:\Python\readme.txt") as f:
    lines = f.readlines()
    print(lines)

Console print: ['Text line 1\n', 'Text line 2\n', 'Text line 3']

Error on Browser: JsException(PythonError: Traceback (most recent call last): File “/lib/python3.10/site-packages/_pyodide/_base.py”, line 429, in eval_code .run(globals, locals) File “/lib/python3.10/site-packages/_pyodide/_base.py”, line 300, in run coroutine = eval(self.code, globals, locals) File “”, line 12, in FileNotFoundError: [Errno 44] No such file or directory: ‘C:\Python\readme.txt’ )

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:15 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
ckavidascommented, May 11, 2022

The error you are receiving is that pyscript cannot read your “readme.txt” file. This is a security feature of your web browser (don’t want some javascript reading your personal files do you?).

Please take a look at the image below: image The “file system” is from emscripten (think of it as a web assembly “container”) to get your files onto this “container” you need to upload them. One method of achieving this is to create a form on your page and write the raw bytes to a file.

1reaction
ckavidascommented, May 12, 2022

@ckavidas can you explain to me why print(os.listdir("/")) prints ['tmp', 'home', 'dev', 'proc', 'lib'] ?

You can read the emscripten file system API documentation here

As you can see in the architecture above, pyscript is built on top of pyodide which includes the emscripten “container”. The file system you are seeing when you run those python commands is the file system of emscripten.

This file system is ephemeral and lives entirely in your web browser.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Avoid Who's Who and Vanity Award Scams - AARP
Fraud experts say you can protect yourself against who's who, fake award and directory scams with a few simple, straightforward precautions.
Read more >
Automated Directory listing Retrieval System Based on ...
Automated Directory listing Retrieval System. Based on Isolated Word Recognition. BERND ALDEFELD, LAWRENCE R. RABINER, FELLOW, IEEE, AARON E. ROSENBERG,.
Read more >
Troubleshooting Voice Recognition - Cisco
Check to make sure that the name is found in the search scope of the user or directory handler, depending on where the...
Read more >
No Directory Service? A Cloud Directory May Be The Tool For ...
It's hard to believe, but some organizations manage identities manually. No directory service? No problem. Try JumpCloud Directory-as-a-Service.
Read more >
Recognition of Spoken Spelled Names for ... - IEEE Xplore
In a recent paper, Rosenberg and Schmidt demonstrated the ap plicability of a speaker-trained, isolated word speech recognizer to the problem of automatic ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found