Skip to content

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

Closed

Description

@karrtikr

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/ Karthik Nadig (@karthiknadig)

Activity

  1. added
    feature-request
    area-environments
    on Feb 8, 2022
  2. 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[/+] on Feb 14, 2022
  3. 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[/+] on Feb 18, 2022
  4. karrtikr commented on Feb 18, 2022

    @karrtikr
    Author

    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)

  5. 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[/+] on Feb 18, 2022
  6. connor4312 commented on Feb 23, 2022

    @connor4312
    Member

    Kartik Raj (@karrtikr) are there verification steps for this?

  7. added
    verification-steps-needed
    on Feb 23, 2022
  8. karrtikr commented on Feb 23, 2022

    @karrtikr
    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.

  9. removed
    verification-steps-needed
    on Feb 23, 2022
  10. rchiodo commented on Feb 23, 2022

    @rchiodo

    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>
    
  11. karrtikr commented on Feb 24, 2022

    @karrtikr
    Author

    Cool. Karthik Nadig (@karthiknadig) should this happen?

  12. karthiknadig commented on Feb 24, 2022

    @karthiknadig
    Member

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

  13. fsjwlf commented on Mar 5, 2022

    @fsjwlf

    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!

  14. karrtikr commented on Mar 5, 2022

    @karrtikr
    Author

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

  15. locked as resolved and limited conversation to collaborators on Apr 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area-environmentsfeature-requestverification-neededverified

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions