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

Respect 'Python: Select Interpreter' and/or '/usr/bin/env' shebang #233

Closed
citizenrich opened this issue Jan 3, 2018 · 9 comments
Closed

Comments

@citizenrich
Copy link

Coming here from:
microsoft/vscode-python#497

I'm curious if code-runner will support the settings for Python path from the command palette (Python: Select Interpreter) or support the '#!/usr/bin/env python{2, 3}' shebang? What should be done to configure code-runner to respect python3?

@formulahendry
Copy link
Owner

You need to below setting (File->Preference->Settings) to specify which Python to use:

{
    "code-runner.executorMap": {
        "python": "/foo/bar/python"
    }
}

For respect the selected python interpreter, use #226 to track.

@formulahendry
Copy link
Owner

@citizenrich FYI, in latest release, Shebang is supported now.

@ClericPy
Copy link

ClericPy commented Mar 6, 2018

Is there any way to ignore shebang?
After latest update,
when I run python2/3 compatible code which has shebang like #! coding:utf-8, code-runner run as 'coding:utf-8 xxx.py' instead of my default setting as 'python3 -u xxx.py'.

btw, I found how to ignore python2's encoding shebang info... just set it in the second line.

Even though it raise the pep8 error: E265 block comment should start with '# '

@formulahendry
Copy link
Owner

@ClericPy How about adding a setting to control whether to ignore shebang?

@ClericPy
Copy link

ClericPy commented Mar 7, 2018

That will be much more flexible, but not very necessary.
Btw, now I found shebang is very useful to distinguish between python2 and python3 (#! python2), because they are .py files both. Now I can set python2 field in "code-runner.executorMap", it's cooler than py-launcher on windows.

@formulahendry
Copy link
Owner

@ClericPy Thanks for your feedback! BTW, a new setting code-runner.respectShebang is added.

@ClericPy
Copy link

ClericPy commented Mar 8, 2018

Thanks for this excellent toolkit.

@ClericPy
Copy link

@formulahendry
User Settings of settings.json is a smart choice. Is it possible to have an option to set ignore the shebang pattern like
code-runner.ignoreShebang: ['#! coding: *', '#! *test*']

@formulahendry
Copy link
Owner

Thanks @ClericPy for the feedback! Have created an issue to track #323

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants