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

Pipx & Virtual Environments #617

Closed
chrisfinazzo opened this issue Jan 31, 2021 · 3 comments
Closed

Pipx & Virtual Environments #617

chrisfinazzo opened this issue Jan 31, 2021 · 3 comments

Comments

@chrisfinazzo
Copy link

Describe the bug

Disclaimer: I am new to Python, apologies if this question has been answered elsewhere.

I want to create a virtual environment which contains its own version of Python and a tool which will be used in several different projects. pipx run APP seems to do this, but the environments are more temporary than I would want.

Previously, I tried to do this using pyenv + pyenv-virtualenv, but couldn't get it to work consistently. In addition, the virtualenv plugin appears to be abandoned, so I need an alternative.

Expected behavior
Having come from rbenv, I expected similar behavior but was disappointed. E.g, a .python-version file with the version of Python that I installed and the environment switches automatically when I navigate to this directory.

With this in mind, what is the current best practice for using virtual environments with pipx? For reference, .local with v3.9 is shown below to illustrate my current setup.

Screen Shot 2021-01-31 at 2 21 56 PM

@itsayellow
Copy link
Contributor

itsayellow commented Jan 31, 2021

You probably want to install your app using pipx install with the --python option

pipx install --python /path/to/python my-package

Which will install my-package and adds whatever apps / binaries it has associated with it in ~/.local/bin if you are using the default settings.

If ~/.local/bin is in your PATH (perhaps because you ran pipx ensurepath once in the past) then you should be able to use those apps from your shell.

pipx is a wrapper around the plain python virtual environment, so if you want more control you can investigate that
https://docs.python.org/3/tutorial/venv.html

@itsayellow
Copy link
Contributor

@chrisfinazzo are you good? Can we close this issue?

@chrisfinazzo
Copy link
Author

@itsayellow I think so. I ended up continuing with the configuration I described - just using the built-in venv module and it seems to work fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants