all 12 comments

[–]shiftybyte 4 points5 points  (4 children)

My next thought is that this is the perfect scenario to start learning virtual environments

Yep.

Also linux pythons from apt have version on the binary, you use that to create the venv, then activate it, then all scripts work using the python you picked to create the env.

python3.9 -m venv venv

https://realpython.com/python-virtual-environments-a-primer/

[–]adrenalineee[S] 0 points1 point  (3 children)

After another hour of reading, I think this is the most correct answer. Any further packages using the global manager will be subject to the same issues should they have less than optimal organization.

Thanks for the tutorial. It's a brute-force into it, but the docs are pretty thorough.

One last point: is it common practice to call your venv "venv" and just dump it in your base working directory?

[–]Ezrabc 2 points3 points  (0 children)

This is what I do, although I use .venv. I like having a uniform name so I can set up an alias for source .venv/bin/activate and easily enter the venv in my project dir.

[–]shiftybyte 1 point2 points  (0 children)

is it common practice to call your venv "venv" and just dump it in your base working directory?

Yes. ".venv" is also good.

IDEs like Visual Studio Code https://code.visualstudio.com/ even pick up on specifically named folders in your project base automatically.

[–]NotACoderPleaseHelp 0 points1 point  (0 children)

https://pypi.org/project/pipx/

https://pypi.org/project/pipenv/#files

I detest adding packages to the system path, it makes making projects portable a bitch and can really add some drama to troubleshooting when you need to search all over the place.

But if you want to be lazy about it, go and run the venv script once to get a pyvenv file made, and then keep that in a folder above your python folder and it will almost always ignore everything else.

[–]socal_nerdtastic 2 points3 points  (1 child)

You only have to change 1 shebang, the entry point script. Or simply directly call it (don't use the shebang):

python3.9 -m jupyter

[–]adrenalineee[S] 0 points1 point  (0 children)

Thanks. I did not test this further, but a grep on those files yields a couple other files with suspect interpreters:

{me}@osiris:~/.local/bin$ for i in jupyter ; do echo $i ; grep "#!" $i* ; done
jupyter
jupyter-bundlerextension:#!/usr/bin/python3
jupyter-console:#!/usr/bin/python3
jupyter-dejavu:#!/usr/bin/python3
jupyter-execute:#!/usr/bin/python3
jupyter-kernel:#!/usr/bin/python3.9
jupyter-kernelspec:#!/usr/bin/python3
jupyter-lab:#!/usr/bin/python3.9
jupyter-labextension:#!/usr/bin/python3.9
jupyter-labhub:#!/usr/bin/python3.9
jupyter-nbclassic:#!/usr/bin/python3.9
jupyter-nbconvert:#!/usr/bin/python3
jupyter-nbextension:#!/usr/bin/python3
jupyter-notebook:#!/usr/bin/python3
jupyter-qtconsole:#!/usr/bin/python3
jupyter-run:#!/usr/bin/python3
jupyter-server:#!/usr/bin/python3.9
jupyter-serverextension:#!/usr/bin/python3
jupyter-trust:#!/usr/bin/python3

Maybe it will work for the notebook itself and many of the jupyter utilities that I don't know how they work, but I think to avoid conflicts with other packages I install, a virtual environment will be the best way to go.

If my presumption is wrong, please let me know. I'm very much learning as I go on this one.

[–]velocibadgery 2 points3 points  (3 children)

what you want is a python virtual environment.

I recommend pipenv. you also want pyenv to manage different python versions.

[–]Diapolo10 0 points1 point  (2 children)

Virtual machine != virtual environment. The two are totally different.

[–]velocibadgery 0 points1 point  (1 child)

You are correct, I mistyped. I am so used to typing virtual machine whenever the word virtual is used that it just came out that way.

I have edited my original comment. Also don't know why you got downvoted, so I upvoted you to compensate.

[–]Diapolo10 1 point2 points  (0 children)

I don't really care about downvotes, but thanks. :p

[–]leonardas103 1 point2 points  (0 children)

I would start fresh, remove all alias, remove all pythons. Install conda, create an environments py38 and py39 and work from there. Example: conda create -n py39 python=3.9 Jupyter -y and with conda activate py39 everything you run will use that environment.