Skip to content

Commit 2850374

Browse files
committed
fix: default to python3 and fallback to python
1 parent c7fff17 commit 2850374

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

Diff for: lib/main.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,20 @@ class PythonLanguageClient extends AutoLanguageClient {
6262
if (venvPath) {
6363
pylsEnvironment.VIRTUAL_ENV = venvPath
6464
}
65-
this.python = replacePipEnvPathVar(atom.config.get("ide-python.python"), venvPath)
65+
66+
let pythonBin = atom.config.get("ide-python.python") || "python3"
67+
if (whichSync(pythonBin, { nothrow: true }) === null) {
68+
pythonBin = "python"
69+
}
70+
71+
this.python = replacePipEnvPathVar(pythonBin, venvPath)
6672

6773
let pyls = atom.config.get("ide-python.pyls") || "pylsp"
6874
// check if it exists
6975
if (whichSync(pyls, { nothrow: true }) === null) {
7076
pyls = "pyls"
7177
}
78+
7279
const childProcess = super.spawn(this.python, ["-m", pyls], {
7380
cwd: projectPath,
7481
env: pylsEnvironment,

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
"title": "Python Executable",
9797
"order": 1,
9898
"type": "string",
99-
"default": "python",
99+
"default": "python3",
100100
"description": "Absolute path of your Python binary. This is used to launch the Python language server. Make sure to install `pyls` for this version of Python. Changes will take effect after a restart of the language server. Use `$PIPENV_PATH/bin/python` if you want to use the pipenv path of your project"
101101
},
102102
"pyls": {

0 commit comments

Comments
 (0)