[Python] VSCode cannot see module 'gymnasium'

Discussão em 'Python' iniciado por Stack, Agosto 30, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to use the module gymnasium (https://gymnasium.farama.org/introduction/basic_usage/) in a python3 script using VSCode IDE. I've only just installed gymnasium for the first time.

    I was under the impression that I had everything installed but encountered this error in VSC:


    Traceback (most recent call last): File ".py", line 1, in import gymnasium as gym ModuleNotFoundError: No module named 'gymnasium'```
    ​

    For simplicity sake, I removed the entire code apart from the import statement, same problem.

    I tried these (in the VSCode terminal):

    pip show gymnasium


    and got:

    Name: gymnasium
    Version: 1.2.0
    Summary: A standard API for reinforcement learning and a diverse set of reference
    environments (formerly Gym).
    Home-page: https://farama.org
    Author:
    Author-email: Farama Foundation <contact@farama.org>
    License: MIT License
    Location: /home/<removed>/anaconda3/lib/python3.12/site-packages
    Requires: cloudpickle, farama-notifications, numpy, typing-extensions
    Required-by: stable_baselines3


    and also:

    pip install gymnasium

    Requirement already satisfied: gymnasium in
    /home/<removed>/anaconda3/lib/python3.12/site-packages (1.2.0)
    Requirement already satisfied: numpy>=1.21.0 in
    /home/<removed>/anaconda3/lib/python3.12/site-packages (from gymnasium) (2.2.6)
    Requirement already satisfied: cloudpickle>=1.2.0 in
    /home/<removed>/anaconda3/lib/python3.12/site-packages (from gymnasium) (3.0.0)
    Requirement already satisfied: typing-extensions>=4.3.0 in /home/<removed>/anaconda3/lib/python3.12/site-packages (from gymnasium) (4.12.2)
    Requirement already satisfied: farama-notifications>=0.0.1 in /home/<removed>/anaconda3/lib/python3.12/site-packages (from gymnasium) (0.0.4)'''


    and yet the code still can't run because

    ModuleNotFoundError: No module named 'gymnasium'


    I re installed gymnasium (and pip install "gymnasium[all]") and still nothing. Getting python3 interpreter running in Terminal and executing '''import gymnasium''' there gives no errors.

    I'm completely lost at this point. It doesn't seem to make any sense. None of this is in an env, only my machine directly. Does anyone have any ideas? Many thanks in advance for any efforts made.

    Continue reading...

Compartilhe esta Página