I’ve been trying to code python on my deck and I can’t for the life of me figure out how to activate the virtual environment. I keep using “source .venv/bin/activate” and it does nothing. No errors, no feedback, doesn’t hang, doesn’t use the environment, nothing.

I’ve tried installing Kitty to see if it was an issue with Konsole but the exact same thing happens. It works fine in Visual Studio Code but I do t want to have to open that every time I try and run a command.

Anyone know why this could be or what I could do to fix it?

Edit to add: This is my first real attempt at Linux idk what I’m doing in a very broad way. Only other time I tried was nearly 15 years ago dual booting Windows/Ubuntu but that lasted like a week because Windows kept blowing up the config and I needed some Windows only programs for school

Solved edit: I don’t exactly know what was up. If I made the venv with the terminal, it would work in the terminal but not work with VSCode’s terminal. If I made it in VSCode it would work in VSCode’s terminal but not the normal terminal. I uninstalled VSCode, made the venv in the Konsole terminal, and everything seems to work fine through PyCharm instead.

  • MajorHavoc@programming.dev
    link
    fedilink
    arrow-up
    2
    ·
    4 days ago

    No module named pip is usually because I have Python earlier than 3.9ish and the vast majority of recipes expect Python 3.9 or later.

    A virtual environment that removes access to pip certainly isn’t working as desired.

    Here’s some things your outputs tell me:

    • The system version of Python has a lot of stuff installed. So using a virtual environment is definitely worth the effort.
    • Your activate script looks fine, on a casual read. (One of the problems we have ruled out is an empty activate file.)
    • Python and pip are both installed and available on your PATH, at least before you activate the virtual environment.
    • Your virtual environment is doing things - at least enough to break pip.

    Having ruled out an empty activate file, I would check on what shell is running. Your activate script expects bash - a classic - but your SteamDeck terminal could default to something else.

    I would also try tossing a 3 at the end of the Python and pip commands. In some situations it can help a missing command be found.

    Try these:

    which python
    which pip
    python -V
    bash
    which python
    which pip
    python -V
    source .venv/bin/activate
    which python
    which python3
    python -V
    which pip
    which pip3
    pip3 freeze
    
    • Ms. ArmoredThirteen@lemmy.zipOP
      link
      fedilink
      English
      arrow-up
      4
      ·
      edit-2
      3 days ago

      Okay so I wiped the .venv that VSCode made again and this time ran the venv creation using python3 -m venv venv. It’s working with command line now but not within VSCode (running into the same issue that I had before but in reverse, so VSCode isn’t recognizing pip or other installed modules like markdown that I added in command line).

      This is starting to feel like maybe a difference in how VSCode handles the virtual environment vs the command line. When I create the venv in one it breaks the other

      Edit: Yeah idk what VSCode is up to. I uninstalled, remade the venv with Konsole, and installed PyCharm instead. Commands through Konsole and the PyCharm terminal are all working as expected now.

      Thank you for the help!

      • Flamekebab@piefed.social
        link
        fedilink
        English
        arrow-up
        1
        ·
        1 day ago

        If it’s any consolation, this is why I don’t use VSCode at work. I got sick of trying to figure out what it was playing at with regards to virtual environments. PyCharm is my go-to.

      • MajorHavoc@programming.dev
        link
        fedilink
        arrow-up
        1
        ·
        3 days ago

        You’re very welcome! I’ve had that issue with VSCode. I tend to create my venv outside of VSCode and force VSCode to use it. I’ve had issues Usually because VSCode is very particular about where the venv folder can be (it really wants it in the root of the current open folder).

        All that said, everyone I know with a PyCharm licence likes it better than VSVcode anyway.

        Have fun! Don’t hesitate to reach out if you get stuck.