*Thought it would be more appropriate to ask in Ask Ubuntu rather than in Stack Overflow.
Using Ubuntu16.04, I am working with python2 (along with some scientific modules) for scientific purposes and decided to switch to python3, and to my understanding; I would need to install the packages again, this time for python3.
As I am a beginner, I especially worry about not removing the packages properly (I would actually prefer to purge them), and of course, not installing the packages properly.
How can I make this transition clean? More specifically I would like to:
- Remove all packages I installed with pip (which are connected to python2).
- Install anew the packages, this time for python3.
For 1. Searching online I came up with
pip freeze | xargs pip uninstall -y
Which should remove the packages I installed, but is it possible to purge?.
For 2. Does it mean I need to install pip3? When installing packages or updating with pip i would get a call:
The directory '/home/.../.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/.../.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Figuring I might have installed something improperly. What should i do differently?
~/.cache/pipnot being owned by the current user can simply be avoided by usingsudo -H pip3 ...instead of justsudo pip3 ...as mentioned in the warning itself. The-Hflag tellssudoto use the target (root) user's home directory instead of the invoking (your) home directory. That way pip3 will store its cache files over there and you don't have problems with them. – Byte Commander Nov 16 '16 at 20:56python3-pipfirst. (sudo apt-get install python3-pip) After that you should ideally always specify the version number of the pip you use, likepip2andpip3instead of plainpip. Normally if you only use the apt packages, plainpipwill always default topip2, but once you upgrade the pips using themselves (which is required in some cases) this is no longer guaranteed. – Byte Commander Nov 16 '16 at 21:00