最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】PyCharm的terminal终端中pipenv –rm出错:You are attempting to remove a virtualenv that Pipenv did not create. Aborting

PyCharm crifan 4640浏览 0评论

折腾:

【已解决】优化整个系统的多个项目的代码结构

期间,想要去删除一个Python的项目中的pipenv的虚拟环境,结果用:

<code>➜  x git:(master) ✗ pipenv --rm
Courtesy Notice: Pipenv found itself running within a virtual environment, so it will automatically use that environment, instead of creating its own for any project. You can set PIPENV_IGNORE_VIRTUALENVS=1 to force pipenv to ignore that environment and create its own instead.
You are attempting to remove a virtualenv that Pipenv did not create. Aborting.
</code>

其中此处有:

Pipfile

Pipfile.lock

而另外也去看了看,的确是有整个虚拟环境的:

<code>➜  xxx git:(master) ✗ll ~/.virtualenvs
lrwxr-xr-x  1 crifan  staff    38B Apr 17 12:02 /Users/crifan/.virtualenvs -&gt; /Users/crifan/.local/share/virtualenvs
➜  xx git:(master) ✗ll /Users/crifan/.local/share/virtualenvs
total 0
drwxr-xr-x   8 crifan  staff   256B Apr 21 14:47 AutocarData-xI-iqIq4
drwxr-xr-x  10 crifan  staff   320B Jul 23 09:19 crawler_ef_challenge-8_TdeiGn
drwxr-xr-x  10 crifan  staff   320B Jul 11 14:03 crawler_qupeiyin_child-SW6GVzwk
drwxr-xr-x   8 crifan  staff   256B Aug 15 10:41 naturling-gXiJ4vtz
drwxr-xr-x   7 crifan  staff   224B May 18 15:58 naturlingRobotDemoServer-SCpLPEyZ
drwxr-xr-x   7 crifan  staff   224B Apr 26 16:29 testDownloadChildes-MYpVabF5

</code>

且当前运行对应命令也是正常工作的:

<code>➜  x git:(master) ✗ pipenv graph
celery==4.1.0
  - billiard [required: &gt;=3.5.0.2,&lt;3.6.0, installed: 3.5.0.3]
  - kombu [required: &gt;=4.0.2,&lt;5.0, installed: 4.1.0]
    - amqp [required: &gt;=2.1.4,&lt;3.0, installed: 2.2.2]
      - vine [required: &gt;=1.1.3, installed: 1.1.4]
  - pytz [required: &gt;dev, installed: 2018.4]
Flask-Cors==3.0.4
  - Flask [required: &gt;=0.9, installed: 1.0.2]
    - click [required: &gt;=5.1, installed: 6.7]
    - itsdangerous [required: &gt;=0.24, installed: 0.24]
    - Jinja2 [required: &gt;=2.10, installed: 2.10]
      - MarkupSafe [required: &gt;=0.23, installed: 1.0]
    - Werkzeug [required: &gt;=0.14, installed: 0.14.1]
  - Six [required: Any, installed: 1.11.0]
Flask-PyMongo==0.5.1
  - Flask [required: &gt;=0.8, installed: 1.0.2]
    - click [required: &gt;=5.1, installed: 6.7]
    - itsdangerous [required: &gt;=0.24, installed: 0.24]
    - Jinja2 [required: &gt;=2.10, installed: 2.10]
      - MarkupSafe [required: &gt;=0.23, installed: 1.0]
    - Werkzeug [required: &gt;=0.14, installed: 0.14.1]
  - PyMongo [required: &gt;=2.5, installed: 3.6.1]
Flask-RESTful==0.3.6
  - aniso8601 [required: &gt;=0.82, installed: 3.0.0]
  - Flask [required: &gt;=0.8, installed: 1.0.2]
    - click [required: &gt;=5.1, installed: 6.7]
    - itsdangerous [required: &gt;=0.24, installed: 0.24]
    - Jinja2 [required: &gt;=2.10, installed: 2.10]
      - MarkupSafe [required: &gt;=0.23, installed: 1.0]
    - Werkzeug [required: &gt;=0.14, installed: 0.14.1]
  - pytz [required: Any, installed: 2018.4]
  - six [required: &gt;=1.3.0, installed: 1.11.0]
gunicorn==19.8.1
openpyxl==2.5.3
  - et-xmlfile [required: Any, installed: 1.0.1]
  - jdcal [required: Any, installed: 1.4]
PyMySQL==0.8.1
redis==2.10.6
requests==2.18.4
  - certifi [required: &gt;=2017.4.17, installed: 2018.4.16]
  - chardet [required: &gt;=3.0.2,&lt;3.1.0, installed: 3.0.4]
  - idna [required: &gt;=2.5,&lt;2.7, installed: 2.6]
  - urllib3 [required: &gt;=1.21.1,&lt;1.23, installed: 1.22]
</code>

pipenv You are attempting to remove a virtualenv that Pipenv did not create. Aborting

Running pipenv destroys a virtual environment it didn’t create or manage. · Issue #819 · pypa/pipenv

Pipenv cannot create virtualenv · Issue #969 · pypa/pipenv

pipenv –where

也是可以检测到环境的,不过也有提示:

<code>➜  x git:(master) ✗ pipenv --where
Courtesy Notice: Pipenv found itself running within a virtual environment, so it will automatically use that environment, instead of creating its own for any project. You can set PIPENV_IGNORE_VIRTUALENVS=1 to force pipenv to ignore that environment and create its own instead.
/Users/crifan/dev/dev_root/xxx
</code>

Courtesy Notice: Pipenv found itself running within a virtual environment

`pipenv –venv` doesn’t work for non-pipenv venv without Pipfile · Issue #1518 · pypa/pipenv

pipenv也是够新的版本:

<code>➜  x git:(master) ✗ pipenv --version
pipenv, version 2018.7.1
</code>

Is there a way to disable / suppress pipenv’s “Courtesy Notice” about virtual environments? · Issue #2527 · pypa/pipenv

突然想起来:

难道是:

PyCharm中运行的此处的terminal:

-》其自动检测到并激活并使用了此处的虚拟环境

-〉导致terminal中无法正常rm删除?

-》那去Mac中普通的iTerm中试试看看

果然是的:

<code>Last login: Wed Aug 15 14:20:37 on ttys013
➜  x git:(master) ✗ pwd
/Users/crifan/dev/dev_root/x
➜  x git:(master) ✗ which python
/usr/bin/python
➜  x git:(master) ✗ pipenv --where
/Users/crifan/dev/dev_root/x
➜  x git:(master) ✗ pipenv --rm
Removing virtualenv (/Users/crifan/.local/share/virtualenvs/x-SCpLPEyZ)...
➜  x git:(master) ✗
</code>

再去确认一下真的被删除了:

<code>➜  x git:(master) ✗ ll /Users/crifan/.local/share/virtualenvs
total 0
drwxr-xr-x   8 crifan  staff   256B Apr 21 14:47 AutocarData-xI-iqIq4
drwxr-xr-x  10 crifan  staff   320B Jul 23 09:19 crawler_xx-8_TdeiGn
drwxr-xr-x  10 crifan  staff   320B Jul 11 14:03 crawler_y-SW6GVzwk
drwxr-xr-x   8 crifan  staff   256B Aug 15 10:41 x-gXiJ4vtz
drwxr-xr-x   7 crifan  staff   224B Apr 26 16:29 testDownloadChildes-MYpVabF5
</code>

【总结】

PyCharm中的terminal终端,是自动检测到了(之前设置了Python解析器,用的是这个)虚拟环境,并自动激活了,导致在虚拟环境里面去

–rm

等操作,无法正常执行。

改为:

普通的终端,比如Mac的iTerm中,去:

<code>pipenv --rm
</code>

即可正常执行,删除当前的虚拟环境。

转载请注明:在路上 » 【已解决】PyCharm的terminal终端中pipenv –rm出错:You are attempting to remove a virtualenv that Pipenv did not create. Aborting

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
82 queries in 0.162 seconds, using 22.21MB memory