Skip to content

python 3.9.2 windows argparse no module _typeshed #5201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Stargateur opened this issue Apr 10, 2021 · 11 comments
Closed

python 3.9.2 windows argparse no module _typeshed #5201

Stargateur opened this issue Apr 10, 2021 · 11 comments

Comments

@Stargateur
Copy link

Stargateur commented Apr 10, 2021

MCVE:

import argparse

Error:

Traceback (most recent call last):
  File "C:\Users\Star\git\optomata\options.py", line 1, in <module>
    from _typeshed import AnyPath
ModuleNotFoundError: No module named '_typeshed'

At this point I don't know what to do.

#5021 doesn't seem related

@Stargateur
Copy link
Author

OK nevermind, visual studio code troll me

@RobertoTables
Copy link

OK nevermind, visual studio code troll me

So, what was the solution?

@Stargateur
Copy link
Author

Stargateur commented Jun 2, 2021

none, I copy paste a code and somehow scroll and never saw the problem was on the first line. (on a 3 line file ??? as I said visual studio troll me I don't know how, it add the import line I think)

@manudut
Copy link

manudut commented Jun 22, 2021

Yeah, happened exactly the same to me...

@Navneety007
Copy link

Yeah same here people

@Akuli
Copy link
Collaborator

Akuli commented Jun 27, 2021

Can we get more details about how this is happening? What editor and version? What is the name of the file you save the code into? Which button do you click in the editor to run it?

@BradMclain
Copy link

I had the same error and thought i was going mad for a second.

For those asking for more details visual studio code autocomplete had added the following at top of file and then scrolled down causing line 1 to be hidden. As @Stargateur indicates this even happens in very short files.

from _typeshed import OpenTextMode

@gabriribeiro5
Copy link

Why this happened?
[answer]:

Hey, guys! This happens because inside the code there's some attribute being called when creating basic functions like

open(file="AnyPath", mode=OpenTextMode)

Notice that 'AnyPath' and 'OpenTextMode' aren't variables you created in your code, they are already built in to python and your code is importing them and, whenever we call something from outside our file.py, we must declare it by using

from module import object

What VSCode did was complete the code with those necessary commands for this attributes to work

And what those attributes do?
I haven't gone that far in my research but I suppose it compiles some "raw" parameter for the function open()

open(file/path/and/name, openingMode): #the openingMode defines the purpose of opening the file
open(myFile, "r") #means the file is open for read only privillege
open(myFile, "w") #means the file is open for write only privilleges
open(myFile, OpenTextMode) #probably means it's open with all privilleges

@agungkrishna-code
Copy link

from typing import TYPE_CHECKING

if TYPE_CHECKING:
from _typeshed import ...

Use this work for me

@itapekhin
Copy link

itapekhin commented Oct 26, 2021

python 3.9
Возникала ошибка:
from _typeshed import Self
ModuleNotFoundError: No module named '_typeshed'

Мне помог импорт:
import typing

@Mwatchorn26
Copy link

Same here, it automatically added the "from _typeshed import" statement at line 1.
I wonder - Is this a VS Code issue, or caused by an extension?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants