Skip to content

Easier configuration of pythonpath #17179

Closed

Description

Discussed in #16652

Originally posted by mrgrieves4 July 11, 2021
As a PyCharm user looking at vscode, one thing that I find pretty unintuitive and awkward is how the pythonpath is setup in vscode. IE having to create a magic file called .env and place a single PYTHONPATH listing all the folders, and there could be a lot of them.

In PyCharm I just need to right click folders and mark/unmark as sources root, and I can also view a list and edit them from there. (Similarly I can exclude folders like this too)

Preferably the config file should use relative paths and be sharable in a team.

Ideally if I rename a folder it would also update the config.

The other thing I found a little confusing is that "pythonpath" in settings etc seems to refer to an interpreter path rather than the actual pythonpath env var, which is what I was expecting it to mean.

Activity

  1. brettcannon commented on Sep 1, 2021

    @brettcannon
    MemberAuthor

    Thanks for the feature request! We are going to give the community 60 days from when this issue was created to provide 5 👍 upvotes on the opening comment to gauge general interest in this idea. If there's enough upvotes then we will consider this feature request in our future planning. If there's unfortunately not enough upvotes then we will close this issue.

  2. abcdehc commented on Sep 8, 2021

    @abcdehc

    Only three days left...
    I think it’s not that users don’t need it...but few people know to give feedback here.
    there are many different tutorials or posts about how to set PYTHONPATH when using vscode, but all of them are too complicated

  3. brettcannon commented on Sep 8, 2021

    @brettcannon
    MemberAuthor

    abcdehc it's actually 52 days left; we are not starting the clock from the Discussion but from we converted it to an issue.

    And we purposefully only want people upvoting who bothered to come to the repo to find a feature and found the corresponding issue. Otherwise we will have to raise the vote threshold even higher to prevent gaming the votes.

  4. vinclei commented on Sep 18, 2021

    @vinclei

    Upvoted. So what's the proper way of adding PYTHONPATH at this moment? Went through some threads and haven't found a clean way..

  5. ryan-feeley commented on Sep 19, 2021

    @ryan-feeley

    For vinclei, AFAIK, there are a few ways, depending on whether you are modifying your global settings, or working per workspace. You may need add your paths in THREE places. This allows them to be added for terminal python, for the python interactive window, and for the pylance code diagnostics tool.

    Someone else can chime in if these examples aren't complete or are out of date.

    "terminal.integrated.env.windows": {
        "PYTHONPATH": "<YOUR PATHS; REMEMBER TO USE DOUBLE // ON WINDOWS>"
    },
    
    "jupyter.runStartupCommands": [
        // Insert list of directories just after cwd, as if it were prepended to PYTHONPATH
        "import os, sys",
        "sys.path.insert(1, os.path.join(<YOUR PATH>)"
    ],
    
    "python.analysis.extraPaths": [<THESE MUST BE RELATIVE PATHS TO YOUR WORKSPACE ROOT>],
    
  6. brettcannon commented on Nov 1, 2021

    @brettcannon
    MemberAuthor

    Thank you for submitting your feature request and everyone who considered it! Unfortunately this issue did not receive enough votes over the allotted time, and so we are closing the issue.

  7. locked as resolved and limited conversation to collaborators on Dec 2, 2021
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

    area-environmentsFeatures relating to handling interpreter environmentsfeature-requestRequest for new features or functionalityneeds community feedbackAwaiting community feedback

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions