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

Python pip doesn't work properly in zsh #984

Open
xzmeng opened this issue Nov 29, 2022 · 3 comments
Open

Python pip doesn't work properly in zsh #984

xzmeng opened this issue Nov 29, 2022 · 3 comments
Labels
bug Something isn't working team: workspace

Comments

@xzmeng
Copy link

xzmeng commented Nov 29, 2022

Bug description

Packages installed with pip under bash cannot be found under zsh.

Steps to reproduce

  1. Open an empty workspace.
  2. $ pip install flask (under bash)
  3. Create a new zsh terminal. (directly from the VSCode, not from an existing bash)
  4. $ python -c "import flask" (under zsh)

Traceback (most recent call last):
File "", line 1, in
ModuleNotFoundError: No module named 'flask'

Expected behavior

Packages should be available regardless of shell type.

Example repository

https://github.com/xzmeng/xzmeng

Anything else?

export PYTHONUSERBASE="$GP_PYENV_MIRROR/user/current"

COPY --chown=gitpod:gitpod python_hook.bash $HOME/.bashrc.d/60-python

I guess the PYTHONUSERBASE environment variable is to allow the packages installed by pip to remain after the workspace is restarted, but if it is only set in bash, other kinds of shells will have inconsistencies.

Is it feasible to put this process in pyenv shims , so that any we don't care about shell types ?

@xzmeng xzmeng added the bug Something isn't working label Nov 29, 2022
@axonasif
Copy link
Member

axonasif commented Nov 29, 2022

Hi @xzmeng, it might be due to a recent change of how we start the IDE process and it's child terminals.

As a workaround, you can follow the below page to have the pyenv dynamic shell environment loaded:

Is it feasible to put this process in pyenv shims , so that any we don't care about shell types ?

Probably, but it might be a bit expensive and more complicated as you have to load pyenv specifically for each shell on every invocation:

@xzmeng
Copy link
Author

xzmeng commented Nov 29, 2022

Source all export variables from bash makes me a bit nervous.
Anyway, thanks for the solutions. I prefer to modify my dotfiles according to the script you supplied.

@akosyakov
Copy link
Member

akosyakov commented Nov 30, 2022

Linked in gitpod-io/gitpod#10105 to look at when we work on support of other shells besides bash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working team: workspace
Projects
No open projects
Status: No status
Development

No branches or pull requests

3 participants