[問題] Linux環境 詢問pip3 套件安裝管理問題
環境是ubuntu
嘗試發文請教,不過我猜應該沒人知道
我儘可能地描述
想了解一下 linux的權限問題 以及 第三方庫管理套件是否真的被移除
問題1
用第三方庫pip3 安裝套件
pip3 install jupyter
沒加sudo 無法找到 jupyter指令
即使重新安裝 加上sudo指令也無法使用
這個我真不知道怎麼改善
若不是使用虛擬機可以回復初始狀態
我就卡死在這邊
若一開始就用以下指令
sudo pip3 install jupyter
可以找到jupyter指令
可正常使用
問題2
sudo pip3 install jupyter
安裝時會出現警告,建議我或許可以加上-H
加上-H後確實不會出現警告
但是我不明白-H有什麼作用 又是為了什麼?
以下是測試過程的描述及圖片
都是用虛擬機 回復初始狀態
分3種情況 測試jupyter指令
1.sudo pip3 install jupyter
2.sudo -H pip3 install jupyter
3.pip3 install jupyter
------------------------------------------------------------------------
sudo apt-get install python3-pip 順利執行安裝
whereis pip3
pip3: /usr/bin/pip3 /usr/share/man/man1/pip3.1.gz
which pip3
/usr/bin/pip3
------------------------------------------------------------------------
再來使用pip3安裝套件
sudo pip3 install jupyter
出現警告 但依然執行安裝
The directory '/home/caesar/.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.
https://imgur.com/ioCZTJa.jpg

安裝jupyter後,測試jupyter指令
https://imgur.com/vsjlOn8.jpg

pip3 uninstall jupyter
執行失敗,權限不足
https://i.imgur.com/q5jJD5s.jpg

sudo pip3 uninstall jupyter
出現警告 ,解安裝成功
反安裝jupyter後,測試jupyter指令
單獨執行 jupyter 還是存在該指令 不是解安裝了嗎?
到底移除了什麼?
但若是用pip3 show jupyter 查詢
則找不到jupyter套件
https://i.imgur.com/BTvL9o5.jpg

------------------------------------------------------------------------
為了不出現警告 嘗試加上參數-H
sudo -H pip3 install jupyter
順利安裝 沒出現任何警告
查詢了-H的功能 在stackoverflow 看到以下這篇
https://stackoverflow.com/questions/43623025/what-does-sudo-h-do
但依然不太了解
加上-H 跟 沒加上的差異 是為了什麼?
安裝jupyter後,測試jupyter指令
感覺跟沒用-H的 看起來相同
https://i.imgur.com/TKNoSmF.jpg

反安裝jupyter 加上-H 不會出現警告
不明白有什麼差異
為了什麼目的 他建議我加上-H ?
https://i.imgur.com/cdh7ch3.jpg

------------------------------------------------------------------------
使用pip3安裝套件 但是不加上sudo
pip3 install jupyter
沒出現警報 正常安裝
安裝jupyter後,測試jupyter指令
找不到jupyter指令
我自己可以發現的差異只有
加上sudo的安裝 使用pip3 show jupyter 其安裝位置
/usr/local/lib/python3.6/dist-packages
沒有sudo的安裝 使用pip3 show jupyter 其安裝位置
/home/caesar/.local/lib/python3.6/site-packages
https://i.imgur.com/DSDSVyO.jpg

由於jupyter指令 找不到
嘗試 pip3 uninstall jupyter 解除安裝
再用 sudo pip3 install jupyter 重新安裝
安裝過程 出現 許多Requirement already satisfied:...
例如:
Requirement already satisfied: nbconvert in
./.local/lib/python3.6/site-packages (from jupyter)
感覺也不是真的重新安裝?
https://i.imgur.com/erH9I1U.jpg

重新加上sudo 安裝 依然找不到jupyter指令
------------------------------------------------------------------------
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 111.241.13.97
※ 文章網址: https://www.ptt.cc/bbs/Python/M.1526802657.A.BB4.html
→
05/20 16:07,
7年前
, 1F
05/20 16:07, 1F
推
05/20 22:16,
7年前
, 2F
05/20 22:16, 2F
→
05/20 22:16,
7年前
, 3F
05/20 22:16, 3F
你說的那篇 應該類似這原因
https://bit.ly/2LepC9a
There was recently malicious code included in pypi. Never use sudo to install
with pip. This is the same as running a virus as root. Either add your local
folder to your PATH or use a virtualenv.
但是 單純用 pip3 uninstall jupyter
就是 沒辦法使用 jupyter指令
似乎要另外增加到 $PATH
如果一開始用 sudo pip3 install jupyter
可以使用 jupyter指令
在解除安裝 sudo pip3 uninstall jupyter
似乎只移除了/usr/local/lib/python3.6/dist-packages/jupyter-1.0.0.dist-info
/usr/local/bin 還是存在 jupyter 檔案
所以 解除安裝後 還是可以使用 jupyter指令
這種種都讓我疑惑
※ 編輯: x246libra (111.241.13.97), 05/20/2018 22:33:09
推
05/21 00:29,
7年前
, 4F
05/21 00:29, 4F
推
05/21 19:50,
7年前
, 5F
05/21 19:50, 5F
→
05/21 19:59,
7年前
, 6F
05/21 19:59, 6F
→
05/21 20:00,
7年前
, 7F
05/21 20:00, 7F
討論串 (同標題文章)
完整討論串 (本文為第 1 之 2 篇):
Python 近期熱門文章
PTT數位生活區 即時熱門文章