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

notebook problems with running conda envs #14123

Closed
KoSv opened this issue Sep 28, 2020 · 10 comments
Closed

notebook problems with running conda envs #14123

KoSv opened this issue Sep 28, 2020 · 10 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster

Comments

@KoSv
Copy link

KoSv commented Sep 28, 2020

Issue Type: Bug
Related: #13071
install python extenstion
open a .ipynb file
set the conda env
on run:

Command failed: . activate myenv && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python /home//.vscode/extensions/ms-python.python-2020.9.111407/pythonFiles/pyvsc-run-isolated.py /home//.vscode/extensions/ms-python.python-2020.9.111407/pythonFiles/printEnvVariables.py bash: activate: Datei oder Verzeichnis nicht gefunden

Extension version: 2020.9.111407
VS Code version: Code 1.49.2 (e5e9e69aed6e1984f7499b7af85b3d05f9a6883a, 2020-09-24T16:26:09.944Z)
OS version: Linux x64 5.8.11-arch1-1

System Info
Item Value
CPUs Intel(R) Core(TM) i5-5300U CPU @ 2.30GHz (4 x 2294)
GPU Status 2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
opengl: enabled_on
protected_video_decode: unavailable_off
rasterization: disabled_software
skia_renderer: enabled_on
video_decode: unavailable_off
vulkan: disabled_off
webgl: enabled
webgl2: enabled
Load (avg) 1, 1, 1
Memory (System) 7.48GB (2.81GB free)
Process Argv --no-sandbox --unity-launch --crash-reporter-id 1b09f273-3ad9-4d17-b97b-06cad50c25cb
Screen Reader no
VM 0%
DESKTOP_SESSION xfce
XDG_CURRENT_DESKTOP XFCE
XDG_SESSION_DESKTOP undefined
XDG_SESSION_TYPE x11
@ghost ghost added the triage-needed Needs assignment to the proper sub-team label Sep 28, 2020
@karthiknadig
Copy link
Member

This occurs due to some limitation we have with the VS Code terminals and conda. Here is a workaround for this:

  1. Turn off auto activation. To do this, disable these two settings, ideally only for the project you are working on:
    image
  2. Exit VS Code.
  3. Open Anaconda Prompt, navigate to your project.
  4. Activate the environment that you want.
  5. Run code . or code project.code-workspace to launch VS Code.

This will give you an activated environment, and the extension will not have to try and activate every time a terminal is created.

@KoSv
Copy link
Author

KoSv commented Sep 28, 2020

This occurs due to some limitation we have with the VS Code terminals and conda. Here is a workaround for this:

  1. Turn off auto activation. To do this, disable these two settings, ideally only for the project you are working on:
    image
  2. Exit VS Code.
  3. Open Anaconda Prompt, navigate to your project.
  4. Activate the environment that you want.
  5. Run code . or code project.code-workspace to launch VS Code.

This will give you an activated environment, and the extension will not have to try and activate every time a terminal is created.

thanks, but this doesn't work for me.
getting the same error.

@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label Sep 28, 2020
@karthiknadig karthiknadig added the bug Issue identified by VS Code Team member as probable bug label Sep 28, 2020
@karrtikr
Copy link

@KoSv Thanks for trying it out? Can you try running the command in the error in bash terminal and see if it works for you? I assume you're on Unix.

. activate myenv && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python /home//.vscode/extensions/ms-python.python-2020.9.111407/pythonFiles/pyvsc-run-isolated.py /home//.vscode/extensions/ms-python.python-2020.9.111407/pythonFiles/printEnvVariables.py

The error Datei oder Verzeichnis nicht gefunden in German translates to File or directory not found, I'm not sure which file this is referring to.

@KoSv
Copy link
Author

KoSv commented Sep 29, 2020

@karrtikr sure. here I've replace my username with <USER>
instead of "." I've added "conda". otherwise I got error bash: activate: Datei oder Verzeichnis nicht gefunden or File or directory not found

{"SHELL": "/bin/bash", "SESSION_MANAGER": "local/Arch:@/tmp/.ICE-unix/813,unix/Arch:/tmp/.ICE-unix/813", "WINDOWID": "79692942", "COLORTERM": "truecolor", "XDG_CONFIG_DIRS": "/etc/xdg", "XDG_MENU_PREFIX": "xfce-", "CONDA_EXE": "/opt/miniconda3/bin/conda", "_CE_M": "", "rvm_prefix": "/home/<USER>", "SSH_AUTH_SOCK": "/tmp/ssh-t9rwvNxoaFwX/agent.962", "MY_RUBY_HOME": "/home/<USER>/.rvm/rubies/ruby-2.6.3", "DESKTOP_SESSION": "xfce", "SSH_AGENT_PID": "963", "DPAT_PASSWORD": "pass", "GTK_MODULES": "canberra-gtk-module:canberra-gtk-module", "XDG_SEAT": "seat0", "RUBY_VERSION": "ruby-2.6.3", "PWD": "/home/<USER>", "LOGNAME": "<USER>", "XDG_SESSION_TYPE": "x11", "CONDA_PREFIX": "/home/<USER>/.conda/envs/myenv", "rvm_version": "1.29.9 (latest)", "XAUTHORITY": "/home/<USER>/.Xauthority", "MOTD_SHOWN": "pam", "HOME": "/home/<USER>", "LANG": "de_DE.UTF-8", "XDG_CURRENT_DESKTOP": "XFCE", "DPAT_USER": "[email protected]", "VTE_VERSION": "6200", "CONDA_PROMPT_MODIFIER": "(myenv) ", "NVM_DIR": "/home/<USER>/.nvm", "rvm_bin_path": "/home/<USER>/.rvm/bin", "GEM_PATH": "/home/<USER>/.rvm/gems/ruby-2.6.3:/home/<USER>/.rvm/gems/ruby-2.6.3@global", "GEM_HOME": "/home/<USER>/.rvm/gems/ruby-2.6.3", "XDG_SESSION_CLASS": "user", "TERM": "xterm-256color", "_CE_CONDA": "", "USER": "<USER>", "CONDA_SHLVL": "1", "DISPLAY": ":0.0", "SHLVL": "1", "NVM_CD_FLAGS": "", "XDG_VTNR": "7", "XDG_SESSION_ID": "1", "CONDA_PYTHON_EXE": "/opt/miniconda3/bin/python", "MOZ_PLUGIN_PATH": "/usr/lib/mozilla/plugins", "XDG_RUNTIME_DIR": "/run/user/1000", "PS1": "(myenv) \\u@\\h \\W/$(parse_git_branch)$ ", "CONDA_DEFAULT_ENV": "myenv", "XDG_DATA_DIRS": "/usr/local/share:/usr/share", "PATH": "/home/<USER>/.conda/envs/myenv/bin:/home/<USER>/.nvm/versions/node/v10.16.3/bin:/opt/miniconda3/condabin:/home/<USER>/.rvm/gems/ruby-2.6.3/bin:/home/<USER>/.rvm/gems/ruby-2.6.3@global/bin:/home/<USER>/.rvm/rubies/ruby-2.6.3/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/home/<USER>/.rvm/bin:/home/<USER>/.rvm/bin", "DBUS_SESSION_BUS_ADDRESS": "unix:path=/run/user/1000/bus", "NVM_BIN": "/home/<USER>/.nvm/versions/node/v10.16.3/bin", "MAIL": "/var/mail/<USER>", "IRBRC": "/home/<USER>/.rvm/rubies/ruby-2.6.3/.irbrc", "rvm_path": "/home/<USER>/.rvm", "_": "/home/<USER>/.conda/envs/myenv/bin/python"}

@karrtikr
Copy link

Thanks that helps, looks like the activation command failed for you. conda activate is the best way to do this on new versions of conda, but source activate should also work provided that it's done in the right directory - and . activate is a shorthand for that.

I think it might be that you don't have the conda bin directory in PATH, and so bash can't find the activate script. Can you please run the following which prints environment variables before activation?

python /home//.vscode/extensions/ms-python.python-2020.9.111407/pythonFiles/pyvsc-run-isolated.py /home//.vscode/extensions/ms-python.python-2020.9.111407/pythonFiles/printEnvVariables.py

I'm particularly interested in PATH, and if it has condabin directory on PATH.

@karrtikr karrtikr added the info-needed Issue requires more information from poster label Sep 30, 2020
@KoSv
Copy link
Author

KoSv commented Sep 30, 2020

aha..
there it is:
"PATH": "/home/USER/.nvm/versions/node/v10.16.3/bin:/opt/miniconda3/condabin:/home/USER/.rvm/gems/ruby-2.6.3/bin:/home/USER/.rvm/gems/ruby-2.6.3@global/bin:/home/USER/.rvm/rubies/ruby-2.6.3/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/home/USER/.rvm/bin:/home/USER/.rvm/bin"

so it has condabin in there. but when I run source activate myenv I get the File or directory not found error. So my conda is not properly installed? But with conda insead ot source I have no problems..

@karrtikr
Copy link

Yes, it should work with both, source should also be able to find the activation script given it's in PATH. So I would think you have a corrupt install.

@karrtikr
Copy link

Actually it's the bin directory that contains the activation script, not condabin, so can you try adding /opt/miniconda3/bin to PATH (or wherever the bin directory is) and see if it works?

@KoSv
Copy link
Author

KoSv commented Sep 30, 2020

OK it works now!
Thank you very much!
I've added the folowing line to my .bashrc file:
export PATH="/opt/miniconda3/bin:$PATH"
After that:

source ~/.bashrc

..
But when I source deactivate I get a DeprecationWarning that I should use conda instead of .
So that you know ;)
Greetings!

@karrtikr
Copy link

Awesome

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

3 participants