如何卸载在/ usr / local / lib中找不到的包

时间:2017-01-11 15:24:14

标签: python flask pip

我关注Flask tutorial,并在某个时候安装了flaskr微博客应用的“不完整”版本。我想用https://github.com/pallets/flask/tree/master/examples/flaskr获得的一个“覆盖”此安装。

但是,在目录~/dev/scratch/flask/examples/flaskr中,如果我尝试运行

sudo pip install --editable .

我得到以下内容:

The directory '/home/kurt/.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/kurt/.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.
Obtaining file:///home/kurt/dev/scratch/flask/examples/flaskr
Requirement already satisfied: flask in /usr/local/lib/python2.7/dist-packages (from flaskr==0.0.0)
Requirement already satisfied: itsdangerous>=0.21 in /usr/local/lib/python2.7/dist-packages (from flask->flaskr==0.0.0)
Requirement already satisfied: click>=2.0 in /usr/local/lib/python2.7/dist-packages (from flask->flaskr==0.0.0)
Requirement already satisfied: Werkzeug>=0.7 in /usr/local/lib/python2.7/dist-packages (from flask->flaskr==0.0.0)
Requirement already satisfied: Jinja2>=2.4 in /usr/lib/python2.7/dist-packages (from flask->flaskr==0.0.0)
Requirement already satisfied: MarkupSafe in /usr/lib/python2.7/dist-packages (from Jinja2>=2.4->flask->flaskr==0.0.0)
Installing collected packages: flaskr
  Found existing installation: flaskr 0.0.0
    Can't uninstall 'flaskr'. No files were found to uninstall.
  Running setup.py develop for flaskr
Successfully installed flaskr

显然,pip发现了无法卸载的“现有安装”。我想'消灭'这个装置;但是,如果我尝试使用目录/usr/local/lib

进行搜索
find . -name '*flaskr*'

我得到的唯一结果是

./python2.7/dist-packages/flaskr.egg-link

如果我rm这个文件,它似乎会自动“回来”。

如何重新安装从其Github存储库克隆的'flaskr'应用程序?

1 个答案:

答案 0 :(得分:0)

我通过回到我安装了flaskr的'不完整'版本的目录并运行命令

解决了这个问题
sudo python setup.py develop --uninstall

产生了确认

running develop
Removing /usr/local/lib/python2.7/dist-packages/flaskr.egg-link (link to .)
Link points to ['/home/kurt/dev/scratch/flask/examples/flaskr', '.']: uninstall aborted

然后,回到带有“完整”版本(~/dev/scratch/flask/examples/flaskr)的目录,我运行了sudo pip install --editable .,然后是export FLASK_APP=flaskr。然后命令

flask initdb

打印预期输出

Initialized the database.