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

best way to start shell / work under different Pythons #631

Closed
2 tasks done
cjw296 opened this issue Nov 15, 2018 · 7 comments
Closed
2 tasks done

best way to start shell / work under different Pythons #631

cjw296 opened this issue Nov 15, 2018 · 7 comments

Comments

@cjw296
Copy link

cjw296 commented Nov 15, 2018

  • I have searched the issues of this repo and believe that this is not a duplicate.
  • I have searched the documentation and believe that my question is not covered.

Question

My system python, as returned by /usr/bin/env python is Python 2.7, so for me, by default I get a Python 2.7 env, which is no longer what I want ;-)

Probably a non poetry question: but how would I change my system, config so that /usr/bin/env python return which python3.7?

In any case, I still need to support 2.7 and 3.6+ on most of my libraries, so it looks like I can do this by doing the following:

python3.7 `which poetry` shell
poetry install

...for a 3.7 env, and the following for a 2.7 env:

poetry shell
poetry install

Is that the best way or have I missed something?
Does this need to be in the docs somewhere or have I just missed them?

@bjoernpollex
Copy link
Contributor

I think the recommended way (not sure if it's documented somewhere) is to use poetry in conjunction with pyenv (see this comment).

@cjw296
Copy link
Author

cjw296 commented Nov 15, 2018

Maybe I'm missing something obvious, but pyenv/pyenv#1244?

@purificant
Copy link

pyenv is the way to go. On a per project basis you can create virtualenv with specific python versions as well as switch between different virtualenvs and python versions as needed with a single command.

Do not go down the path of trying to use your existing system interpreter for your project. The system interpreter is included in order to run your system, let it do that, and manage interpreter for your project separately. Frequently your operating system and your project will have conflicting requirements as far as python / virtualenv setup goes and trying work around those conflicts will just eat up your productive time.

@cjw296
Copy link
Author

cjw296 commented Nov 15, 2018

@purificant - I've found most system pythons to be sane, but sure.
The problem I have with pyenv, which I describe in pyenv/pyenv#1244, is that attempting to build python from source all over the place seems crazy. Mac and Windows provide nice installers that have everything build the "right" way and provide a clean, base install (with things like working ssl, readline and zlib, to name a few that often go wrong...) and the various "alt" distributions provided by operating systems like RHEL and debian also provide a great base. Then there's the Pythons built and provided by the conda guys that provide great, clean, fully functional bases in user space.

How can I 'register' these with pyenv?

@purificant
Copy link

Sounds like pyenv is not a good choice for your use case.

If you require using a specific build of python, then I would create a virtual environment using that interpreter, activate it, which should point python to the desired version / build and then run poetry inside it. Poetry will detect that it's inside a virtual environment and install packages accordingly.

@cjw296
Copy link
Author

cjw296 commented Nov 15, 2018

Ah, true. I guess pyenv is close to what I want, but building everything seems silly. That's a rant for the pyenv tracker though, so I think I have my answer here :-)

@cjw296 cjw296 closed this as completed Nov 15, 2018
Copy link

github-actions bot commented Mar 3, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants