You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
New feature of Python extension will change my conda environment settings. #22752
Originally posted by Roderick-Stinson January 11, 2024
Because of the feature of python extension, which is Activate Environments in Terminal Using Environment Variables, python extension will delete an environment variable $CONDA_PREFIX,
the show environment contributions file looks like this:
you can see there isn't a variable named CONDA_PREFIX, instead there are CONDA_PREFIX_2andCONDA_PREFIX_3.
this leads to crash of conda
So could you please help solve this question? It's really annoying. My current solution is add export CONDA_PREFIX=/home/wangzihan/miniconda3 in .bashrc
Same. I'm using macOS, zsh, and miniforge installed by homebrew. Even when I turned off the option terminal.integrated.shellIntegration.enabled I can no longer access my python environment installed by conda in the usual way. Seems like it breaks conda's initialization or path configs in .zshrc? Haven't quite got time digging into it yet, but here's my error reports/outputs for your information.
[WARNING]: Console output during zsh initialization detected.
some Powerlevel10k outputs...
-- console output produced during zsh initialization follows --
# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<
Traceback (most recent call last):
File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.11/site-packages/conda/exception_handler.py", line 17, in __call__
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.11/site-packages/conda/cli/main.py", line 105, in main_sourced
print(activator.execute(), end="")
^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.11/site-packages/conda/activate.py", line 199, in execute
return getattr(self, self.command)()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.11/site-packages/conda/activate.py", line 165, in activate
builder_result = self.build_activate(self.env_name_or_prefix)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.11/site-packages/conda/activate.py", line 343, in build_activate
return self._build_activate_stack(env_name_or_prefix, False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.11/site-packages/conda/activate.py", line 433, in _build_activate_stack
deactivate_scripts = self._get_deactivate_scripts(old_conda_prefix)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.11/site-packages/conda/activate.py", line 765, in _get_deactivate_scripts
for entry in os.scandir(join(prefix, "etc", "conda", "deactivate.d"))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen posixpath>", line 76, in join
TypeError: expected str, bytes or os.PathLike object, not NoneType
`$ /opt/homebrew/Caskroom/miniforge/base/bin/conda shell.posix activate base`
environment variables:
CIO_TEST=<not set>
CONDA_EXE=/opt/homebrew/Caskroom/miniforge/base/bin/conda
CONDA_PREFIX_2=/opt/homebrew/Caskroom/miniforge/base/envs/envname
CONDA_PREFIX_3=/opt/homebrew/Caskroom/miniforge/base
CONDA_PYTHON_EXE=/opt/homebrew/Caskroom/miniforge/base/bin/python
CONDA_ROOT=/opt/homebrew/Caskroom/miniforge/base
CONDA_SHLVL=4
CURL_CA_BUNDLE=<not set>
INFOPATH=/opt/homebrew/share/info:
LD_PRELOAD=<not set>
MANPATH=/opt/homebrew/share/man:/usr/share/man:/usr/local/share/man:/Library/T
eX/Distributions/.DefaultTeX/Contents/Man:/opt/homebrew/share/man::
PATH=/opt/homebrew/opt/python@3.11/libexec/bin:/Users/username/Library/Android
/sdk/tools:/Users/username/Library/Android/sdk/tools/bin:/Users/username/Lib
rary/Android/sdk/platform-tools:/opt/homebrew/bin:/opt/homebrew/sbin:/
usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/s
bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/lo
cal/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/us
r/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/
appleinternal/bin:/Library/Apple/usr/bin:/Library/TeX/texbin:/usr/loca
l/share/dotnet:~/.dotnet/tools
REQUESTS_CA_BUNDLE=<not set>
SSL_CERT_FILE=<not set>
active environment : None
shell level : 4
user config file : /Users/username/.condarc
populated config files : /opt/homebrew/Caskroom/miniforge/base/.condarc
conda version : 23.9.0
conda-build version : not installed
python version : 3.11.0.final.0
virtual packages : __archspec=1=m2
__osx=14.2.1=0
__unix=0=0
base environment : /opt/homebrew/Caskroom/miniforge/base (writable)
conda av data dir : /opt/homebrew/Caskroom/miniforge/base/etc/conda
conda av metadata url : None
channel URLs : https://conda.anaconda.org/conda-forge/osx-arm64
https://conda.anaconda.org/conda-forge/noarch
package cache : /opt/homebrew/Caskroom/miniforge/base/pkgs
/Users/username/.conda/pkgs
envs directories : /opt/homebrew/Caskroom/miniforge/base/envs
/Users/username/.conda/envs
platform : osx-arm64
user-agent : conda/23.9.0 requests/2.31.0 CPython/3.11.0 Darwin/23.2.0 OSX/14.2.1
UID:GID : 501:20
netrc file : None
offline mode : False
An unexpected error has occurred. Conda has prepared the above report.
If you suspect this error is being caused by a malfunctioning plugin,
consider using the --no-plugins option to turn off plugins.
Example: conda --no-plugins install <package>
Alternatively, you can set the CONDA_NO_PLUGINS environment variable on
the command line to run the command without plugins enabled.
Example: CONDA_NO_PLUGINS=true conda install <package>
# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<
Traceback (most recent call last):
File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.11/site-packages/conda/exception_handler.py", line 17, in __call__
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.11/site-packages/conda/cli/main.py", line 105, in main_sourced
print(activator.execute(), end="")
^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.11/site-packages/conda/activate.py", line 199, in execute
return getattr(self, self.command)()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.11/site-packages/conda/activate.py", line 165, in activate
builder_result = self.build_activate(self.env_name_or_prefix)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.11/site-packages/conda/activate.py", line 343, in build_activate
return self._build_activate_stack(env_name_or_prefix, False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.11/site-packages/conda/activate.py", line 433, in _build_activate_stack
deactivate_scripts = self._get_deactivate_scripts(old_conda_prefix)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.11/site-packages/conda/activate.py", line 765, in _get_deactivate_scripts
for entry in os.scandir(join(prefix, "etc", "conda", "deactivate.d"))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen posixpath>", line 76, in join
TypeError: expected str, bytes or os.PathLike object, not NoneType
`$ /opt/homebrew/Caskroom/miniforge/base/bin/conda shell.posix activate envname`
environment variables:
CIO_TEST=<not set>
CONDA_EXE=/opt/homebrew/Caskroom/miniforge/base/bin/conda
CONDA_PREFIX_2=/opt/homebrew/Caskroom/miniforge/base/envs/envname
CONDA_PREFIX_3=/opt/homebrew/Caskroom/miniforge/base
CONDA_PYTHON_EXE=/opt/homebrew/Caskroom/miniforge/base/bin/python
CONDA_ROOT=/opt/homebrew/Caskroom/miniforge/base
CONDA_SHLVL=4
CURL_CA_BUNDLE=<not set>
INFOPATH=/opt/homebrew/share/info:
LD_PRELOAD=<not set>
MANPATH=/opt/homebrew/share/man:/usr/share/man:/usr/local/share/man:/Library/T
eX/Distributions/.DefaultTeX/Contents/Man:/opt/homebrew/share/man::
PATH=/opt/homebrew/opt/python@3.11/libexec/bin:/Users/username/Library/Android
/sdk/tools:/Users/username/Library/Android/sdk/tools/bin:/Users/username/Lib
rary/Android/sdk/platform-tools:/opt/homebrew/bin:/opt/homebrew/sbin:/
usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/s
bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/lo
cal/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/us
r/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/
appleinternal/bin:/Library/Apple/usr/bin:/Library/TeX/texbin:/usr/loca
l/share/dotnet:~/.dotnet/tools
REQUESTS_CA_BUNDLE=<not set>
SSL_CERT_FILE=<not set>
active environment : None
shell level : 4
user config file : /Users/username/.condarc
populated config files : /opt/homebrew/Caskroom/miniforge/base/.condarc
conda version : 23.9.0
conda-build version : not installed
python version : 3.11.0.final.0
virtual packages : __archspec=1=m2
__osx=14.2.1=0
__unix=0=0
base environment : /opt/homebrew/Caskroom/miniforge/base (writable)
conda av data dir : /opt/homebrew/Caskroom/miniforge/base/etc/conda
conda av metadata url : None
channel URLs : https://conda.anaconda.org/conda-forge/osx-arm64
https://conda.anaconda.org/conda-forge/noarch
package cache : /opt/homebrew/Caskroom/miniforge/base/pkgs
/Users/username/.conda/pkgs
envs directories : /opt/homebrew/Caskroom/miniforge/base/envs
/Users/username/.conda/envs
platform : osx-arm64
user-agent : conda/23.9.0 requests/2.31.0 CPython/3.11.0 Darwin/23.2.0 OSX/14.2.1
UID:GID : 501:20
netrc file : None
offline mode : False
An unexpected error has occurred. Conda has prepared the above report.
If you suspect this error is being caused by a malfunctioning plugin,
consider using the --no-plugins option to turn off plugins.
Example: conda --no-plugins install <package>
Alternatively, you can set the CONDA_NO_PLUGINS environment variable on
the command line to run the command without plugins enabled.
Example: CONDA_NO_PLUGINS=true conda install <package>
and my ms-python.python extension in Environment changes file writes:
Hi there Okky Mabruri (@okkymabruri) Thank you! It helps a lot! Seems like the new python extension automatically turned it false?
Just for anyone also encountering the same issue: After reactivating this option, the python command still doesn't look for conda's python binaries by default (as possibly configured in shell's rc file). However, after running conda activate envName in the integrated shell, it can eventually find conda's pythons.
No special settings needed other than the ones specified. Just open a Python file to activate the extension and make sure to perform the steps to reproduce the issue.
Because we have not heard back with the information we requested, we are closing this issue for now. If you are able to provide the info later on, then we will be happy to re-open this issue to pick up where we left off.
Activity
lethefrost commentedon Jan 17, 2024
Same. I'm using macOS, zsh, and miniforge installed by homebrew. Even when I turned off the option
terminal.integrated.shellIntegration.enabledI can no longer access my python environment installed by conda in the usual way. Seems like it breaks conda's initialization or path configs in .zshrc? Haven't quite got time digging into it yet, but here's my error reports/outputs for your information.and my
ms-python.pythonextension inEnvironment changesfile writes:and in
.zshrcI have the conda default initialization asand
which condaoutputs the following function:Does anyone know what path I should assign to
CONDA_PREFIXif I'm to try the workaround mentioned by several users? Thank you!okkymabruri commentedon Jan 17, 2024
Hi Brett Cannon (@brettcannon) lethefrost
I resolved that issue by enabling terminal.integrated.inheritEnv setting.
"terminal.integrated.inheritEnv": truelethefrost commentedon Jan 18, 2024
Hi there Okky Mabruri (@okkymabruri) Thank you! It helps a lot! Seems like the new python extension automatically turned it false?
Just for anyone also encountering the same issue: After reactivating this option, the
pythoncommand still doesn't look for conda's python binaries by default (as possibly configured in shell's rc file). However, after runningconda activate envNamein the integrated shell, it can eventually find conda's pythons.karrtikr commentedon Jan 23, 2024
Hi all, apologies for the issue. Could anyone send us the debug logs which can help diagnose it:
Developer: Set log levelcommandTraceDeveloper: Reload WindowcommandOutput for
Pythonin theOutputpanel (View→Output, change the drop-down the upper-right of theOutputpanel toPython)lethefrost commentedon Jan 25, 2024
Hi there, what settings should these logs be running under, and is there any specific action we should do to ensure wanted information is logged?
karrtikr commentedon Jan 25, 2024
No special settings needed other than the ones specified. Just open a Python file to activate the extension and make sure to perform the steps to reproduce the issue.
brettcannon commentedon Mar 13, 2024
Because we have not heard back with the information we requested, we are closing this issue for now. If you are able to provide the info later on, then we will be happy to re-open this issue to pick up where we left off.