Skip to content
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

Wrong python binary is used #3229

Closed
NeroVanbiervliet opened this issue Nov 7, 2018 · 7 comments
Closed

Wrong python binary is used #3229

NeroVanbiervliet opened this issue Nov 7, 2018 · 7 comments

Comments

@NeroVanbiervliet
Copy link

Environment data

  • VS Code version: 1.28.2 (snap)
  • Extension version (available under the Extensions sidebar): 2018.9.2
  • OS and version: Ubuntu 18.10
  • Python version (& distribution if applicable, e.g. Anaconda): 3.6.7
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): N/A
  • Relevant/affected Python packages and their versions: None

Actual behavior

Python files are execute with the wrong python3 binary. Therefore, installed packages with pip cannot be found.

Python interpreter has been set to /usr/bin/python3, but it does not seem to use that binary. The versions are different as can be seen in this screenshot:

python3-binary-magic

Expected behavior

Python versions in vscode terminal and system shell should be the same.

Steps to reproduce

No idea if this can be reproduced on other machines.

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

##########Linting Output - pylint##########
************* Module update_ci
1,0,error,E0401:Unable to import 'gitlab'

------------------------------------------------------------------
Your code has been rated at 7.73/10 (previous run: 7.73/10, +0.00)

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help)

bootstrap-window.js:195 [uncaught exception]: TypeError: Cannot read property 'isWrapped' of undefined
onUnexpectedError @ bootstrap-window.js:195
bootstrap-window.js:198 TypeError: Cannot read property 'isWrapped' of undefined
    at Buffer.getWrappedRangeForLine (Buffer.ts:302)
    at BufferStringIterator.next (Buffer.ts:421)
    at Linkifier._linkifyRows (Linkifier.ts:101)
    at Linkifier.ts:76
onUnexpectedError @ bootstrap-window.js:198
Buffer.ts:302 Uncaught TypeError: Cannot read property 'isWrapped' of undefined
    at Buffer.getWrappedRangeForLine (Buffer.ts:302)
    at BufferStringIterator.next (Buffer.ts:421)
    at Linkifier._linkifyRows (Linkifier.ts:101)
    at Linkifier.ts:76
@brettcannon
Copy link
Member

What you're after is #1765 . Basically this is because we don't control your PATH when you select a global Python interpreter to prevent knock-on effects like other tools suddenly being shadowed beyond just python3 (unlike when you use a virtual or conda environment where we can activate that and get you the semantics you're after).

@NeroVanbiervliet
Copy link
Author

I don't understand why the issue is related to PATH. In the above screenshot, I reference the python interpreters with their full path: /usr/bin/python3. They should point to the same interpreter, but don't (according to version numbers)?

@brettcannon
Copy link
Member

That I don't know as we don't have anything to do with the terminal and its PATH resolution. But do notice your terminal is sh and not e.g. bash in VS Code.

@NeroVanbiervliet
Copy link
Author

Good point. I verified and the same issue arises with sh:

sh-python3-version

I understand that the terminal is not of your concern, but the same issue applies for linting and executing python files. They all run with the wrong python interpreter. This is my main problem, because packages that I installed on python 3.6.7 are not detected in VS code.

@brettcannon
Copy link
Member

Unfortunately we can't avoid it because something has to execute the commands on our behalf. Your best option is to either figure out why your system is doing this, try updating VS Code (1.29 came out the other day), or specify the full paths to things like your linters.

@brettcannon
Copy link
Member

E.g. you should be specifying the full path to the interpreter you want in your "python.pythonPath" setting and thus be avoiding this when using the extension.

@NeroVanbiervliet
Copy link
Author

I found the real problem: it is related to the flatpak packaging. It is explained in this issue in the flathub repo.

@lock lock bot locked as resolved and limited conversation to collaborators Dec 17, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants