question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[feature request] get python.pythonPath from cwd rather than system wide.

See original GitHub issue

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 leave python.pythonPath blank

Expected behavior

find python at current path

use python set py pyenv I can set .python-version in some parent-folder

Steps to reproduce:

  • pyenv local <some-version> at ~/dev
  • open ~/dev/project1 as a project
  • current python.pythonPath is the system-wide, not read from current folder.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:20 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
neverfoxcommented, Apr 2, 2018

@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:

> pyenv versions
* system (set by /usr/local/opt/pyenv/version)
  3.6.5
  /usr/local/Cellar/pyenv/1.2.3/versions/3.6.5/envs/NDF
  /usr/local/Cellar/pyenv/1.2.3/versions/3.6.5/envs/PonyGE2
  /usr/local/Cellar/pyenv/1.2.3/versions/3.6.5/envs/nrf
  NDF
  PonyGE2
  nrf

Now: Screenshot of Python: Select Interpreter Notice that the PonyGE2 and nrf venvs are nowhere to be seen. It’s almost like it’s taking the first one in order under the 3.6.5 parent and ignoring the rest.

1reaction
gwaxcommented, Dec 8, 2017

pyenv is a tool that replaces python and installed python tools (pylint, flake8, etc.) with symbolic links and routes requests to different commands based on global/local configuration.

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:

pyenv install 2.7.14
pyenv install 3.5.0
pyenv install 3.6.3
pyenv virtualenv 3.5.0 somepython
pyenv global 3.6.3
which python  # /Users/waksman/.pyenv/shims/python
python --version  # Python 3.6.3
pyenv which python  # /Users/waksman/.pyenv/versions/3.6.3/bin/python
mkdir -P two/subdir threefive/subdir

cd two
pyenv local 2.7.14
# Inside two/** python, pip, etc. will point to pyenv 2.7.14
python --version  # Python 2.7.14
pyenv which python  # /Users/waksman/.pyenv/versions/2.7.14/bin/python
cat .python-version  # 2.7.14
cd subdir
python --version  # Python 2.7.14
cd ../..

cd threefive
pyenv local somepython
# Inside threefive/** python, pip, etc. will point to pyenv somepython, which is 3.5.0 but with package installs specific to somepython
python --version  # Python 3.5.0
pyenv which python  # /Users/waksman/.pyenv/versions/somepython/bin/python
cat .python-version  # somepython
cd subdir
python --version  # Python 3.5.0
cd ../..

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 pyenv which python for any given path.

Read more comments on GitHub >

github_iconTop Results From Across the Web

4. Using Python on Windows — Python 3.11.1 documentation
This document aims to give an overview of Windows-specific behaviour you should know about when using Python on Microsoft Windows. Unlike most Unix...
Read more >
Understanding the Python Path Environment Variable in Python
Pythonpath is a special environment variable that provides guidance to the Python interpreter about where to find various libraries and ...
Read more >
How to Find Path Information in Python - Dummies.com
In this article, learn about the sources of path information in Python, and how to find path information using two different methods.
Read more >
3. Using Python on Windows
Unlike the PATH variable, the launcher will correctly select the most appropriate version of Python. It will prefer per-user installations over system-wide ones ......
Read more >
Install a Python package into a different directory using pip?
The --target switch is the thing you're looking for: pip install --target=d:\somewhere\other\than\the\default package_name.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found