-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[feature request] get python.pythonPath from cwd rather than system wide. #363
Comments
Not quite sure what you are after here as I don't use |
@brettcannon Thanks, this plugin doesn't pick-up the python-version which |
It is used as an alternative to virtualenvs and is one of the more common ways of managing python versions on OSX. So, for example:
The crux of it is that executing a command from a given folder will result in pyenv routing it to the correct environment (assuming bash_profile/bashrc has been run and set up pyenv). So, the ask (I think) is that when linting/executing/whatever a given source file, execute the command from the location of that file. Alternatively, the interpreter could be set by using |
@gwax Thanks @brettcannon I find that this plugin now works as I expected. So this issue can be closed. |
I continue to have trouble with this, requiring me to manually select interpreter whenever I look at a different workspace and would appreciate if this issue could be re-opened. |
I assume you're executing pyenv before you launch VS Code from the shell? I.e. your example is missing a |
I am not opening VS Code from the terminal, I am opening it via a shortcut. I am also using a multi-root workspace and different root folders have different pyenv environments. My examples were to illustrate the behavior of pyenv. Essentially, pyenv knows how to route to the appropriate virtualenv and it would be great if the interpreter could be taken from pyenv instead of having to be specified manually. After pyenv init (usually in .bash_profile or .bashrc), running |
For prioritization context: pyenv is (to my knowledge) on of the more common ways of managing Python environments on OSX; and, it is possible to work around this by manually associating the appropriate interpreter with the project root. |
So the issue is that But we could bake in explicit support for |
Yeah, and problematically, the environment mutation is working directory dependent so even if I launch Explicit pyenv support seems reasonable and it's probably a good way to avoid having to pull pyenv setup from an enclosing environment (running |
I have a variant of this issue which is that I use
I (and other folk) have been moving away from Edited to add: Also, |
Same issue here, and it's currently preventing me from using VSCode as my Python IDE since I always use pyenv and virtualenvs (so instead I'm using Spacemacs, which handles all this just fine). More specifically, I don't just use pyenv but pyenv with the pyenv-virtualenv plugin. So you have installed pyenv versions, which VSCode picks up as valid interpreters in its list (though not automatically the way pyenv would do it), but then you have virtualenvs under each version. pyenv handles this by using shims. The shims are first in the path so you always go through them to get to pyenv, which then handles interpreting your environment to find the right version and location. I tried setting my |
Yes, pyenv does mutate the environment but I don't think that mutation is essential to how it works (though I could be wrong). Instead, as I said, it works through a shim executable (which you could set in your |
Having lived with this a bit longer, I find it's a lot less difficult to work around than I previously thought but there are a few minor issues that make things annoying and some other possible nice to haves.
Annoyances and nice to haves:
|
See #1167 for tracking the request to add support for |
@gwax All of mine aren't showing up, so I'm curious how you accomplished (or lucked into) that. I'd be fine with most of the issues you mention if I at least got a complete list, but look at this:
Now: |
@neverfox I see the same behavior. I created a pyenv virtualenv and set that to global. vscode does see that as an interpreter. However, any other virtualenvs do not show up. At present I use the Select Interpreter to reference the exact python version for the workspace/directory which does work. Will start tracking the other open issue for completion. |
@gadams999 Thanks for confirming. Sounds like this should be its own issue. |
@neverfox please open a separate issue as that is a feature request since we only detect virtual environments that are kept in your workspace folder or created by pipenv. |
@gwax I'm actually really curious how that's able to do the trick for the other executables like pylint, flake8, etc since you're not telling the extension about where to find the right copy like you are with the interpreter. Perhaps it works because the extension sets something in the environment that effects the shims for them to be directed appropriately? |
Environment data
VS Code version: 1.8.1
Python Extension version: 0.8.0
Python Version: 3.6.3
OS and version: macOS 10.13.2
Actual behavior
use system
python
if I leavepython.pythonPath
blankExpected behavior
find
python
at current pathSteps to reproduce:
pyenv local <some-version>
at~/dev
~/dev/project1
as a projectpython.pythonPath
is the system-wide, not read from current folder.The text was updated successfully, but these errors were encountered: