Skip to content

conda run -n MY-ENV python FILE.py uses the base interpreter instead of environment interpreter. #9587

@Parskatt

Description

@Parskatt

I'm submitting a...

  • bug report
  • feature request

Current Behavior

Using conda run -n for environments, when shell is in specified environment, leads to default conda interpreter being used instead of environment interpreter. This leads to python not finding packages e.g. numpy.

Steps to Reproduce

On w10 with miniconda + at least 1 environment.

Running:

conda activate MY-ENV
conda run -n MY-ENV python .\test.py

In PS or cmd on the python file

import sys
print(sys.executable)

Prints: "conda path"\python.exe (in my case: C:\Users\parsk\Miniconda3\python.exe i.e. the base conda environment)

Expected Behavior

The environment python interpreter should be called, e.g. C:\Users\parsk\Miniconda3\envs\MY-ENV\python.exe

Environment Information

`conda info`

     active environment : MY-ENV
    active env location : C:\Users\parsk\Miniconda3\envs\MY-ENV
            shell level : 2
       user config file : C:\Users\parsk\.condarc
 populated config files :
          conda version : 4.7.12
    conda-build version : not installed
         python version : 3.7.4.final.0
       virtual packages : __cuda=10.1
       base environment : C:\Users\parsk\Miniconda3  (writable)
           channel URLs : https://repo.anaconda.com/pkgs/main/win-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/win-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://repo.anaconda.com/pkgs/msys2/win-64
                          https://repo.anaconda.com/pkgs/msys2/noarch
          package cache : C:\Users\parsk\Miniconda3\pkgs
                          C:\Users\parsk\.conda\pkgs
                          C:\Users\parsk\AppData\Local\conda\conda\pkgs
       envs directories : C:\Users\parsk\Miniconda3\envs
                          C:\Users\parsk\.conda\envs
                          C:\Users\parsk\AppData\Local\conda\conda\envs
               platform : win-64
             user-agent : conda/4.7.12 requests/2.22.0 CPython/3.7.4 Windows/10 Windows/10.0.18362
          administrator : False
             netrc file : None
           offline mode : False

`conda config --show-sources`

(empty)

`conda list --show-channel-urls`

# packages in environment at C:\Users\parsk\Miniconda3:
#
# Name                    Version                   Build  Channel
altgraph                  0.16.1                   pypi_0    pypi
asn1crypto                1.2.0                    py37_0    defaults
ca-certificates           2019.10.16                    0    defaults
certifi                   2019.9.11                py37_0    defaults
cffi                      1.13.0           py37h7a1dbc1_0    defaults
chardet                   3.0.4                 py37_1003    defaults
conda                     4.7.12                   py37_0    defaults
conda-package-handling    1.6.0            py37h62dcd97_0    defaults
console_shortcut          0.1.1                         3    defaults
cryptography              2.8              py37h7a1dbc1_0    defaults
future                    0.18.2                   pypi_0    pypi
idna                      2.8                      py37_0    defaults
menuinst                  1.4.16           py37he774522_0    defaults
openssl                   1.1.1d               he774522_3    defaults
pefile                    2019.4.18                pypi_0    pypi
pip                       19.3.1                   py37_0    defaults
powershell_shortcut       0.0.1                         2    defaults
pycosat                   0.6.3            py37hfa6e2cd_0    defaults
pycparser                 2.19                     py37_0    defaults
pyinstaller               3.5                      pypi_0    pypi
pyopenssl                 19.0.0                   py37_0    defaults
pyqt5                     5.13.2                   pypi_0    pypi
pyqt5-sip                 12.7.0                   pypi_0    pypi
pyqtchart                 5.13.1                   pypi_0    pypi
pysocks                   1.7.1                    py37_0    defaults
python                    3.7.4                h5263a28_0    defaults
pywin32                   223              py37hfa6e2cd_1    defaults
pywin32-ctypes            0.2.0                    pypi_0    pypi
requests                  2.22.0                   py37_0    defaults
ruamel_yaml               0.15.46          py37hfa6e2cd_0    defaults
setuptools                41.4.0                   py37_0    defaults
six                       1.12.0                   py37_0    defaults
sqlite                    3.30.0               he774522_0    defaults
tqdm                      4.36.1                     py_0    defaults
urllib3                   1.24.2                   py37_0    defaults
vc                        14.1                 h0510ff6_4    defaults
vs2015_runtime            14.16.27012          hf0eaf9b_0    defaults
wheel                     0.33.6                   py37_0    defaults
win_inet_pton             1.1.0                    py37_0    defaults
wincertstore              0.2                      py37_0    defaults
yaml                      0.1.7                hc54c509_2    defaults

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateindicate issues/PRs that are duplicates of anotherlocked[bot] locked due to inactivityplugins::runpertains to conda-runsource::communitycatch-all for issues filed by community memberstype::bugdescribes erroneous operation, use severity::* to classify the type

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions