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.

ModuleNotFoundError: No module named 'typing.io'; 'typing' is not a package

See original GitHub issue

Issue Description

Bug

OS: Windows 10 Professional x64, Build 1909 Python: 3.8.10 VSCode: 1.58.2 AREPL: 2.0.2

When using importlib.resources, AREPL generates the error:

File "C:\Program Files\Python38\lib\importlib\resources.py", line 13, in <module>
    from typing.io import BinaryIO, TextIO
ModuleNotFoundError: No module named 'typing.io'; 'typing' is not a package

Minimal Example

  1. Create python 3.8.10 virtual environment with venv in project folder:
py -m venv .venv
  1. Create VSCode user settings to point AREPL to virtual environment:
"AREPL.pythonPath": "${workspaceFolder}\\.venv\\Scripts\\python.exe"
  1. Create file demo.py in project folder
  2. Import importlib.resources in demo.py:
import importlib.resources as rsrc
  1. Click cat button for AREPL to run repl

Expected Behavior AREPL uses virtual environment and is able to import importlib.resources

Screenshots image

image

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:13 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Almenoncommented, Oct 15, 2022

I believe this is related to AREPL’s typescript code.

The Typescript code doesn’t have much to do with the python code outside of spawning the process and pipe I/O. The issue is more likely to be with the AREPL python code, which does some funky stuff around importing so there is a fresh state each time. https://github.com/Almenon/AREPL-backend/blob/master/python/arepl_python_evaluator.py

One thing that’s pretty weird is that I don’t get this bug with python 3.9, only 3.8 and 3.10 (haven’t checked 3.11). I also can’t reproduce the issue in a unit test. @adam-grant-hendry do you get this issue with 3.9?

Also, adding “typing.io” to the modules_to_keep variable in C:\Users\<yourUser>\.vscode\extensions\almenon.arepl-2.0.3\node_modules\arepl-backend\python\arepl_python_evaluator.py (insert after line 27) fixes the issue on my end. Does it fix the issue for you?

1reaction
gulash007commented, Jun 28, 2022

Hello, can you please explain how exactly did you fixed it ? Do i need to do it on VS code. Where can i find the ressource.py file ?

Sorry for a late reply. For what it’s worth, the resources.py file is a part of the importlib library. On my mac it’s located at /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/importlib/resources.py.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ImportError: No module named 'typing' when trying to install a ...
pip itself is failing as it tries to import typing and typing is not installed. so you cannot run pip install to fix...
Read more >
Importerror no module named typing : Tricks to Fix
Importerror no module named typing error cause is either Typing python module is not available or its installation is improper.
Read more >
[Fixed] ModuleNotFoundError: No module named 'typing ...
Solution Idea 1: Install Library typing-extensions ... The most likely reason is that Python doesn't provide typing-extensions in its standard library. You need ......
Read more >
ImportError: No module named 'typing' in Python | bobbyhadz
The Python "ImportError: No module named 'typing'" occurs when we use an outdated version of pip . To solve the error, run the...
Read more >
Python: ImportError: No module named typing
Problem: Installing joblib module is throwing error: # pip install joblib ... ImportError: No module named typing Trying to install typing, ...
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