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

[codespaces] Python virtual environment setup #922

Closed
danieljurek opened this issue Oct 19, 2022 · 6 comments
Closed

[codespaces] Python virtual environment setup #922

danieljurek opened this issue Oct 19, 2022 · 6 comments

Comments

@danieljurek
Copy link
Member

danieljurek commented Oct 19, 2022

When launching Python codespaces alerts come up before build... What's the earliest time we could/should run the vscode azd restore command? Python projects should also communicate with the Python extension, if possible, and indicate the appropriate interpreter (this could get interesting with multiple python projects)

Example error message in first run:

image

Example error message in first debugging run:

image

To fix:

  1. Run the "Restore API" task to get a python virtual environment on the instance
  2. Ctrl+Shift+P > Python: Select Interpreter ... select the one created in the restore step
@rajeshkamal5050
Copy link

@philliphoff do we see this extension issue on VSCode?

@rajeshkamal5050 rajeshkamal5050 added this to the On Deck milestone Oct 26, 2022
@ghost ghost added the needs-triage For new issues label Nov 1, 2022
@weikanglim
Copy link
Contributor

This reproduces on devcontainer and Codespaces.

The root cause seems to be that VSCode server is creating a settings.json in /home/vscode/.vscode-server/data/Machine/settings.json containing the following settings:

{
	"python.defaultInterpreterPath": "/usr/local/bin/python",
	"python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8",
	"python.formatting.blackPath": "/usr/local/py-utils/bin/black",
	"python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf",
	"python.linting.banditPath": "/usr/local/py-utils/bin/bandit",
	"python.linting.flake8Path": "/usr/local/py-utils/bin/flake8",
	"python.linting.mypyPath": "/usr/local/py-utils/bin/mypy",
	"python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle",
	"python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle",
	"python.linting.pylintPath": "/usr/local/py-utils/bin/pylint"
}

which /usr/local/bin/python doesn't exist. Commenting out this file fixes the issue. Still investigating further...

@rajeshkamal5050
Copy link

@weikanglim @danieljurek any updates on the investigation? Is this a blocker for Codespaces release in Jan?

@vhvb1989
Copy link
Member

vhvb1989 commented Dec 8, 2022

This reproduces on devcontainer and Codespaces.

The root cause seems to be that VSCode server is creating a settings.json in /home/vscode/.vscode-server/data/Machine/settings.json containing the following settings:

{
	"python.defaultInterpreterPath": "/usr/local/bin/python",
	"python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8",
	"python.formatting.blackPath": "/usr/local/py-utils/bin/black",
	"python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf",
	"python.linting.banditPath": "/usr/local/py-utils/bin/bandit",
	"python.linting.flake8Path": "/usr/local/py-utils/bin/flake8",
	"python.linting.mypyPath": "/usr/local/py-utils/bin/mypy",
	"python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle",
	"python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle",
	"python.linting.pylintPath": "/usr/local/py-utils/bin/pylint"
}

which /usr/local/bin/python doesn't exist. Commenting out this file fixes the issue. Still investigating further...

@weikanglim , have you tried overriding the python.defaultInterpreterPath setting within the template folder settings?
Maybe if you set it to python3 instead of python ?

@weikanglim
Copy link
Contributor

@rajeshkamal5050 This was fixed in devcontainers/features#258. Verifying before closing out.

@weikanglim
Copy link
Contributor

Verified working as expected. Closing.

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

No branches or pull requests

4 participants