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

Use conda run for conda environments for running python files and possibly installation #18479

Closed
karrtikr opened this issue Feb 8, 2022 · 8 comments · Fixed by #18520
Closed
Assignees
Labels
area-environments Features relating to handling interpreter environments feature-request Request for new features or functionality verification-needed Verification of issue is requested verified Verification succeeded
Milestone

Comments

@karrtikr
Copy link

karrtikr commented Feb 8, 2022

Seems like this bit was missed:
image

Feel free to also add it in the iteration planning board. Note we should not be using the OUTPUT_MARKER_SCRIPT for running/debugging files, so add an option in this API

public async getRunPythonArgs(env: CondaEnvInfo): Promise<string[] | undefined> {
const condaVersion = await this.getCondaVersion();
if (condaVersion && lt(condaVersion, CONDA_RUN_VERSION)) {
return undefined;
}
const args = [];
if (env.name) {
args.push('-n', env.name);
} else {
args.push('-p', env.prefix);
}
return [this.command, 'run', ...args, '--no-capture-output', 'python', OUTPUT_MARKER_SCRIPT];
}
to skip that.

cc/ @karthiknadig

@karrtikr karrtikr added feature-request Request for new features or functionality needs PR area-environments Features relating to handling interpreter environments labels Feb 8, 2022
@karrtikr karrtikr added this to the February 2022 milestone Feb 8, 2022
@karrtikr karrtikr changed the title Use conda run for conda environments when running python files Use conda run for conda environments for running python files and installing modules Feb 14, 2022
@karrtikr karrtikr changed the title Use conda run for conda environments for running python files and installing modules Use conda run for conda environments for running python files Feb 18, 2022
@karrtikr
Copy link
Author

karrtikr commented Feb 18, 2022

It turns out we cannot use conda run for installing modules. Reason is:

  • We already activate the conda environment before we send the installation command.
  • conda run then kind of double activates the environment, so the module isn't installed where it's expected.
  • When we run, for eg. a linter using conda run, it cannot find the module.

Seems like another bug on conda. (conda/conda#11305)

@karrtikr karrtikr changed the title Use conda run for conda environments for running python files Use conda run for conda environments for running python files and possibly installation Feb 18, 2022
@karthiknadig karthiknadig added the verification-needed Verification of issue is requested label Feb 19, 2022
@connor4312
Copy link
Member

@karrtikr are there verification steps for this?

@connor4312 connor4312 added the verification-steps-needed Steps to verify are needed for verification label Feb 23, 2022
@karrtikr
Copy link
Author

Thanks for testing:

  • Install conda
  • Create conda environment: conda create -n python
  • Select it as interpreter
  • Use play button on the top right of the editor to run the python file
  • Make sure 'conda run' is used

If you need more elaboration please let me know.

@karrtikr karrtikr removed the verification-steps-needed Steps to verify are needed for verification label Feb 23, 2022
@rchiodo rchiodo added the verified Verification succeeded label Feb 23, 2022
@rchiodo
Copy link

rchiodo commented Feb 23, 2022

Debug python file doesn't use conda run? Does that matter?

Otherwise verified running uses conda run:

(RunPythonTest) PS D:\Source\Testing_3> & C:/Users/aku91/miniconda3/Scripts/conda.exe run -n condaTestPath --no-capture-output --live-stream python d:/Source/Testing_3/debug_python.py
foo
bar
baz
1.5.1
(RunPythonTest) PS D:\Source\Testing_3>

@karrtikr
Copy link
Author

Cool. @karthiknadig should this happen?

@karthiknadig
Copy link
Member

No that should not happen. we might have a bug.

@fsjwlf
Copy link

fsjwlf commented Mar 5, 2022

Hi~ I updated my VSCode, and found that the new version seemed to fix this bug.
However, after I run the python code, the terminal shows "run -n base --no-capture-output --live-stream python xxx.py". And the result was printed. And immediately the result was cleared. I cannot see my result!

@karrtikr
Copy link
Author

karrtikr commented Mar 5, 2022

@fsjwlf Can you create a new issue for this? Thanks!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-environments Features relating to handling interpreter environments feature-request Request for new features or functionality verification-needed Verification of issue is requested verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants