Monday July 19, 2021
I have been away from my home base for a long time and I needed to return. Took the train to Madrid, so I only did some light reading.
- The Linux Command Line (2nd ed) – by William Shotts (No Starch Press)
- Machine Learning Models – A Beginner’s Guide to Key Concepts and Pitfalls (1st ed) – by Alice Zheng (O’ Reilly)
Tuesday July 20, 2021
Because pipenv is a smash up of pip and virtualenvs, I will use it instead of virtualenv. Plus Pipfile.lock which is analogous to requirements.txt automatically updates when packages are installed.
brew install pipenv wait…..
Homebrew installation is discouraged because each time the Homebrew Python is upgraded, which Pipenv depends on, users have to re-install Pipenv, and perhaps all virtual environments managed by it.
— the pipenv docs page
So where do I install pipenv…? If I install it with pip, as I did, then it goes in the site-package directory of the python version that is being used. I suppose if I keep the pyenv global fixed then it might not matter. But there pyenv is so modular that I can’t guarantee that will be easy to do and if I get a very long list of versions in pyenv then finding the version that contains the pipenv will be difficult. So, I am experimenting with pipx.
Now, I have installed pipx with hombrew and then installed pipenv and it is detecting that pipenv is already installed in the pyenv shims. This is the case even though the version of python that contains pipenv is not activated as the pyenv global.
After doing some cleaning up I finally get the setting I want. The PATH contains an additional directory
~/.local/bin where my pipenv symlinks are place. The symlinks point to
~/.local/pipx/venvs. That looks good because it is not connected to any other package or version of python or Homebrew. So, if anything else changes on the system changes this should stay the same. So, here, I can download jupyter notebook and be confident that it will be there if anything updates or changes.
Duplicate PATH problem resolved for the moment
I had a problem that my PATH contained multiple duplicates of pyenv shims. At one point I just restarted my Shell and it went down to just one shim…So, I think I was entering
exec $SHELL instead of restarting the Shell which injected a shim to the PATH each time. So much for my understanding of Shell and system files and commands. I have a lot to learn.
Cleaning the PATH directories when the problem reoccurs
Finally, I have learned how to clean up the PATH list if it ever gets cluttered with duplicates. You only need to put
echo $PATH into your shell, copy the directories that you want to persist, then in your
~/.bashrc you will add
PATH="<the directories you want>" and then
export PATH. You can restart you Shell and the check your PATH and it should be what you have selected. You can comment out these commands with
# at the beginning of the lines in your
~/.bashrc when you are finished.
By the way, your file might be different given the different shells that your system is using. For example, mine is not
~/.bashrc instead it is
~/.zshrc. You can determine this if you enter
ps -p$$ in the shell command line. Then you can also see in your home directory the hidden dot files (the files that start with a .) which you can reveal with
ls -a in your home directory. You should see one of these
-rc files or possible you need to add it to
~/.profile, idk. I’m picking this up as I go and this is what I know.