Skip to content

python 3.9.2 windows argparse no module _typeshed #5201

Closed

Description

@Stargateur

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

Activity

  1. Stargateur commented on Apr 10, 2021

    @Stargateur
    Author

    OK nevermind, visual studio code troll me

  2. RobertoTables commented on Jun 2, 2021

    @RobertoTables

    OK nevermind, visual studio code troll me

    So, what was the solution?

  3. Stargateur commented on Jun 2, 2021

    @Stargateur
    Author

    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)

  4. manudut commented on Jun 22, 2021

    @manudut

    Yeah, happened exactly the same to me...

  5. Navneety007 commented on Jun 27, 2021

    @Navneety007

    Yeah same here people

  6. Akuli commented on Jun 27, 2021

    @Akuli
    Collaborator

    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?

  7. BradMclain commented on Jun 28, 2021

    @BradMclain

    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
    
  8. gabriribeiro5 commented on Aug 12, 2021

    @gabriribeiro5

    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

  9. agungkrishna-code commented on Aug 21, 2021

    @agungkrishna-code

    from typing import TYPE_CHECKING

    if TYPE_CHECKING:
    from _typeshed import ...

    Use this work for me

  10. itapekhin commented on Oct 26, 2021

    @itapekhin

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

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

  11. Mwatchorn26 commented on Dec 30, 2021

    @Mwatchorn26

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions