ModuleNotFoundError: No module named 'typing.io'; 'typing' is not a package
See original GitHub issueBug
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
- Create
python 3.8.10
virtual environment withvenv
in project folder:
py -m venv .venv
- Create VSCode user settings to point AREPL to virtual environment:
"AREPL.pythonPath": "${workspaceFolder}\\.venv\\Scripts\\python.exe"
- Create file
demo.py
in project folder - Import
importlib.resources
indemo.py
:
import importlib.resources as rsrc
- Click cat button for AREPL to run repl
Expected Behavior
AREPL uses virtual environment and is able to import importlib.resources
Screenshots
Issue Analytics
- State:
- Created 2 years ago
- Comments:13 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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?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.