How to use pip3 without sudo privileges
In my case, there are several python3.x version installed in my system before, and I had to type python3.x and sudo pip3 for developing the code every time, which disturbed me.
Here are the methods I tried to solve this problem. Now I am able to type only the python3 command for the newest python3.8 use and pip3 for installing modules without root privileges.
- python3.x ... -> python3 ...
- sudo pip3.x install ... -> pip3 install / python3 -m pip install ...
1. Install pip3 locally under /home/$USER/.local/bin/.
$ wget https://bootstrap.pypa.io/get-pip.py
$ python3 get-pip.py --user
2. Edit ~/.bashrc
$ export PATH=$PATH:~/.local/bin
$ export PYTHONPATH=$PYTHONPATH:/usr/lib/python3.8/dist-packages
$ source ~/.bashrc
3. Delete redundant pip path or error: ModuleNotFoundError: No module named 'pip._vendor.retrying' will be reported.
$ sudo rm -r /usr/lib/python3/dist-packages/pip
Check:
$ python3 --version
留言
張貼留言