<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>pip &#8211; 李辉 / Grey Li</title>
	<atom:link href="https://greyli.com/tag/pip/feed/" rel="self" type="application/rss+xml" />
	<link>https://greyli.com</link>
	<description>一个编程和写作爱好者的在线记事本</description>
	<lastBuildDate>Thu, 06 Nov 2025 11:36:11 +0000</lastBuildDate>
	<language>zh-CN</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.9.26</generator>

<image>
	<url>https://greyli.com/wp-content/uploads/2025/03/avatar-500-compressed-144x144.jpg</url>
	<title>pip &#8211; 李辉 / Grey Li</title>
	<link>https://greyli.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>安装 Python 依赖出现 MarkupSafe ImportError &#8230; Feature 报错的解决方法</title>
		<link>https://greyli.com/pip-pipenv-install-python-package-markupsafe-setup-py-importerror-cannot-import-name-feature/</link>
		<comments>https://greyli.com/pip-pipenv-install-python-package-markupsafe-setup-py-importerror-cannot-import-name-feature/#respond</comments>
		<pubDate>Thu, 09 Apr 2020 03:40:05 +0000</pubDate>
		<dc:creator><![CDATA[李辉]]></dc:creator>
				<category><![CDATA[计算机与编程]]></category>
		<category><![CDATA[Flask]]></category>
		<category><![CDATA[Flask Web开发实战]]></category>
		<category><![CDATA[MarkupSafe]]></category>
		<category><![CDATA[pip]]></category>
		<category><![CDATA[Pipenv]]></category>

		<guid isPermaLink="false">http://greyli.com/?p=2899</guid>
		<description><![CDATA[这个报错在 3 月 8 号 setuptools 发布新版本之后出现，通常会在安装 Python 依赖时触发。 [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>这个报错在 3 月 8 号 setuptools 发布新版本之后出现，通常会在安装 Python 依赖时触发。</p>
<h2>报错信息</h2>
<p>使用 pip 安装依赖时的报错如下：</p>
<pre class="">Collecting markupsafe==1.0
  Downloading https://.../MarkupSafe-1.0.tar.gz (14 kB)
    ERROR: Command errored out with exit status 1:
     command: '...\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'...\\pip-install-bsormril\\markupsafe\\setup.py'"'"'; __file__='"'"'...\\pip-install-bsormril\\markupsafe\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base '...\pip-install-bsormril\markupsafe\pip-egg-info'
         cwd: ...\pip-install-bsormril\markupsafe\
    Complete output (5 lines):
    Traceback (most recent call last):
      File "&lt;string&gt;", line 1, in &lt;module&gt;
      File "...\pip-install-bsormril\markupsafe\setup.py", line 6, in &lt;module&gt;
        from setuptools import setup, Extension, Feature
    ImportError: cannot import name 'Feature'
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.</pre>
<p>使用 Pipenv 安装依赖时的报错如下：</p>
<pre class="">An error occurred while installing markupsafe==1.0 --hash=sha256:a6be69091dac236ea9c6bc7d012beab42010fa914c459791d627dad4910eb665! Will try again.
Installing initially failed dependencies…
[pipenv.exceptions.InstallError]:   File "...\Python\Python36\site-packages\pipenv\core.py", line 1874, in do_install
[pipenv.exceptions.InstallError]:       keep_outdated=keep_outdated
[pipenv.exceptions.InstallError]:   File "...Python\Python36\site-packages\pipenv\core.py", line 1253, in do_init
[pipenv.exceptions.InstallError]:       pypi_mirror=pypi_mirror,
[pipenv.exceptions.InstallError]:   File "...\Python\Python36\site-packages\pipenv\core.py", line 859, in do_install_dependencies
[pipenv.exceptions.InstallError]:       retry_list, procs, failed_deps_queue, requirements_dir, **install_kwargs
[pipenv.exceptions.InstallError]:   File "...\Python\Python36\site-packages\pipenv\core.py", line 763, in batch_install
[pipenv.exceptions.InstallError]:       _cleanup_procs(procs, not blocking, failed_deps_queue, retry=retry)
[pipenv.exceptions.InstallError]:   File "...\Python\Python36\site-packages\pipenv\core.py", line 681, in _cleanup_procs
[pipenv.exceptions.InstallError]:       raise exceptions.InstallError(c.dep.name, extra=err_lines)
[pipenv.exceptions.InstallError]: ['Looking in indexes: https://.../pypi/simple', 'Collecting markupsafe==1.0', '  Using cached https://.../MarkupSafe-1.0.tar.gz (14 kB)']
[pipenv.exceptions.InstallError]: ['ERROR: Command errored out with exit status 1:', '
command: \'...\\.virtualenvs\\helloflask-evdb6idn\\scripts\\python.exe\' -c \'import sys, setuptools, tokenize; sys.argv[0] = \'"\'"\'...\pip-install-pkgojp4t\\\\markupsafe\\\\setup.py\'"\'"\'; 
__file__=\'"\'"\'...\\\\pip-install-pkgojp4t\\\\markupsafe\\\\setup.py\'"\'"\';f=getattr(tokenize, \'"\'"\'open\'"\'"\', open)(__file__);code=f.read().replace(\'"\'"\'\\r\\n\'"\'"\', \'"\'"\'\\n\'"\'"\');f.close();exec(compile(code, __file__, \'"\'"\'exec\'"\'"\'))\' egg_info --egg-base \'...\\pip-install-pkgojp4t\\markupsafe\\pip-egg-info\'', '
cwd: ...\\pip-install-pkgojp4t\\markupsafe\\', '    Complete output (5 lines):', '    
Traceback (most recent call last):', '      
File "&lt;string&gt;", line 1, in &lt;module&gt;', ' 
File "...\\pip-install-pkgojp4t\\markupsafe\\setup.py", line 6, in &lt;module&gt;', '
from setuptools import setup, Extension, Feature', "
ImportError: cannot import name 'Feature'", '----------------------------------------',
'ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.']
ERROR: ERROR: Package installation failed...</pre>
<p>其他工具输出类似，主要异常信息是 MarkupSafe setup.py: ImportError: cannot import name Feature。通常会在安装 Flask 项目的依赖时发生，因为 MarkupSafe 是 Flask 的依赖之一。</p>
<h2>原因和解决方法</h2>
<p>出现这个报错的原因是因为 Python 打包工具 setuptools 在 <a href="https://setuptools.readthedocs.io/en/latest/history.html#v46-0-0" rel="nofollow noopener">46.0.0 版本</a>删掉了弃用的 <code>Feature</code>，而 MarkupSafe 刚好在 setup.py 文件里导入了这个类，所以会出现报错。</p>
<p>解决方法很多，最直接的是更新 MarkupSafe 到最新版本（1.1.1），新版本去掉了对 Feature 类的导入。如果使用 requirements.txt 存储依赖列表，那就把 MarkupSafe 的版本号改成 1.1.1（找到 MarkupSafe 开头那一行，替换版本号）：</p>
<pre class="">MarkupSafe==1.1.1</pre>
<p>然后重新执行：</p>
<pre class="">$ pip install -r requirements.txt</pre>
<p>对于 Pipenv，可以直接执行：</p>
<pre class="">$ pipenv install markupsafe==1.1.1</pre>
<p>如果你是《Flask Web 开发实战》的读者，正在为第一部分的示例程序安装依赖，那你还需要执行下面的命令固定 sendgrid-python 的版本（它在新版本添加了不向后兼容的 API 变动）：</p>
<pre class="">$ pipenv install sendgrid==5.3.0</pre>
<h2>《Flask Web 开发实战》读者备注</h2>
<p>如果你在 2020 年 3 月 8 号到 4 月 5 号之间买了《Flask Web 开发实战》，把示例程序克隆到了本地，然后尝试运行 pipenv install 或 pip install -r requirements.txt 命令来安装依赖，那很大概率你会遇到这个问题。</p>
<p>除了使用上面的方法之外，你还可以通过更新本地代码来解决。我最近给所有示例程序的依赖文件做了一次更新，除了书里涉及的 API 产生变动的依赖，其他依赖都已经更新到最新版本。</p>
<p>你可以使用下面的命令来更新你在本地的程序仓库（注意这会重置你对源码进行的修改）：</p>
<pre class="">$ git fetch --all
$ git fetch --tags
$ git reset --hard origin/master</pre>
<p>然后重新执行一次 pipenv install 或 pip install -r requirements.txt 即可解决这个问题。如果遇到其他虚拟环境和依赖安装的问题可以参考<a href="http://greyli.com/flask-web-book-pipenv-problem-solved/">这篇文章</a>解决。</p>
<p>相关链接：</p>
<ul>
<li><a href="https://discuss.helloflask.com/t/topic/458">https://discuss.helloflask.com/t/topic/458</a></li>
<li><a href="https://github.com/pallets/markupsafe/issues/57">https://github.com/pallets/markupsafe/issues/57</a></li>
<li><a href="https://github.com/pypa/setuptools/issues/65">https://github.com/pypa/setuptools/issues/65</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>https://greyli.com/pip-pipenv-install-python-package-markupsafe-setup-py-importerror-cannot-import-name-feature/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>要不我们还是用回 virtualenv/venv 和 pip 吧</title>
		<link>https://greyli.com/back-to-virtualenv-venv-and-pip/</link>
		<comments>https://greyli.com/back-to-virtualenv-venv-and-pip/#comments</comments>
		<pubDate>Sat, 07 Sep 2019 06:11:35 +0000</pubDate>
		<dc:creator><![CDATA[李辉]]></dc:creator>
				<category><![CDATA[计算机与编程]]></category>
		<category><![CDATA[pip]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[venv]]></category>
		<category><![CDATA[virtualenv]]></category>
		<category><![CDATA[依赖管理]]></category>
		<category><![CDATA[虚拟环境管理工具]]></category>

		<guid isPermaLink="false">http://greyli.com/?p=2551</guid>
		<description><![CDATA[这篇文章没什么新东西，只是介绍古老又靠谱的 Python 虚拟环境和依赖管理方式：virtualenv/ven [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>这篇文章没什么新东西，只是介绍古老又靠谱的 Python 虚拟环境和依赖管理方式：virtualenv/venv+pip。一来方便被我在《Flask 入门教程》和《Flask Web 开发实战》带入 <a href="http://greyli.com/do-not-use-pipenv/">Pipenv 坑</a>的初学者了解基础工具的用法，二来方便其他 Python 初学者参考，自己顺便做个总结。<span data-offset-key="2c438-0-0">如果你想了解更多详细内容，Python 官方教程</span><a class="Link ztext-link" href="https://docs.python.org/3/tutorial/venv.html" target="_blank" rel="noopener" data-offset-key="2c438-1-0" data-editable="true"><span data-offset-key="2c438-1-0">这一章</span></a><span data-offset-key="2c438-2-0">写的更好，可以替代这篇文章。</span></p>
<p>既然大部分试图简化 Python 虚拟环境和依赖管理工作流程的新工具都不够稳定，继续使用 virtualenv/venv 和 pip 这样的底层工具也是一个不错的选择，而且大多数人也是这么做的。它们虽然用起来有一点麻烦，但至少更可靠。</p>
<h2>基本概念</h2>
<p>下面是一些基本概念：</p>
<ul>
<li><a href="https://www.pypa.io/en/latest/">PyPA</a>：指 Python Packaging Authority，一个维护 Python 打包相关项目的小组，相关项目具体见 <a href="https://github.com/pypa">https://github.com/pypa</a>。</li>
<li><a href="https://pip.pypa.io/en/stable/">pip</a>：Python 包安装器 。</li>
<li><a href="https://virtualenv.pypa.io/en/stable/">virtualenv</a>：Python 虚拟环境管理工具。</li>
<li><a href="https://docs.python.org/3/library/venv.html">venv</a>：Python 标准库内置的虚拟环境管理工具，Python 3.3 加入，Python 3.5 开始作为管理虚拟环境的推荐工具，用法类似 virtualenv。如果你使用 Python 3，推荐使用 venv 来替代 virtualenv。</li>
</ul>
<h2>使用 virtualenv/venv 管理虚拟环境</h2>
<h3>venv 模块</h3>
<p>如果你使用 Python 3（具体说是 Python 3.3 及以上版本），推荐使用标准库内置的 <a href="https://docs.python.org/3/library/venv.html">venv 模块</a>替代 virtualenv，两者的使用方式基本相同，唯一不同的是创建虚拟环境的方式。</p>
<p>如果你使用 Python 2，那就只能选择 virtualenv，你需要额外安装它。我先假设你已经安装了 pip，因为在 Python 2 &gt;=2.7.9 或 Python 3 &gt;=3.4 这些版本的 Python 会一并安装 pip，其他版本可以参考文档的<a href="https://pip.pypa.io/en/stable/installing/">安装部分</a>。在 Windows 下使用下面的命令安装 virtualenv：</p>
<pre class="">$ pip install virtualenv</pre>
<p>其他操作系统可以使用下面的命令安装：</p>
<pre class="">$ sudo pip install virtualenv</pre>
<p>尽管<a href="https://pages.charlesreid1.com/dont-sudo-pip/">不推荐使用 sudo pip</a> 的方式安装 Python 包，但这仍然是最简单和统一的方式。更安全的方式是使用系统包管理器来安装，或是使用 pip &#8211;user 方式安装。</p>
<h3>创建虚拟环境</h3>
<p>假设我们的项目名叫 snow，创建对应的文件夹然后切换到根目录：</p>
<pre class="">$ mkdir snow
$ cd snow</pre>
<p>如果使用 venv，那么使用下面的命令创建虚拟环境，其中 snow-venv 是虚拟环境的名字，也作为创建的虚拟环境文件夹名称，你可以自由修改（通常会使用 venv 或 env 作为虚拟环境名）：</p>
<pre class="">$ python -m venv snow-venv</pre>
<p>如果使用 virtualenv，则使用下面的命令：</p>
<pre class="">$ virtualenv snow-venv</pre>
<p>这会在当前目录创建名为 snow-venv 的虚拟环境文件夹，你需要把这个文件夹名称加入 .gitignore 文件以便让 Git 忽略。</p>
<h3>激活虚拟环境</h3>
<p>通过执行对应的激活脚本来激活虚拟环境，不同操作系统的激活命令（激活脚本及路径）有一点不同。Windows（CMD.exe）使用下面的命令激活：</p>
<pre class="">$ snow-venv\scripts\activate</pre>
<p>Linux 和 macOS（bash/zsh）使用下面的命令：</p>
<pre class="">$ source snow-venv/bin/activate</pre>
<p>或：</p>
<pre class="">$ . snow-venv/bin/activate</pre>
<p>类似的，其他终端程序可以执行对应的激活脚本来激活虚拟环境。</p>
<p>激活虚拟环境以后，命令行提示符前会显示当前虚拟环境的名字：</p>
<pre class="">(snow-venv) $</pre>
<p>使用 deactivate 命令可以退出虚拟环境。</p>
<h2>使用 pip 管理依赖</h2>
<p>简单列一下基本用法，虽然大部分人都很熟悉了……以 Flask 为例，首先是安装依赖：</p>
<pre class="">(snow-venv) $ pip install flask</pre>
<p>更新依赖：</p>
<pre class="">(snow-venv) $ pip install --upgrade flask</pre>
<p>或是：</p>
<pre class="">(snow-venv) $ pip install -U flask</pre>
<p>卸载依赖：</p>
<pre class="">(snow-venv) $ pip uninstall flask</pre>
<p>除此之外，还有 pip show flask 命令可以查看某个依赖的详细信息，pip list 列出所有依赖。</p>
<p>下面的命令可以手动生成依赖列表：</p>
<pre class="">(snow-venv) $ pip freeze &gt; requirements.txt</pre>
<p>如果你需要手动开发依赖和生产依赖，可以手动把开发相关的依赖放到单独的文件，比如 requirements-dev.txt。</p>
<p>当你需要在新的机器创建程序运行环境时，（创建虚拟环境后）只需要使用下面的命令从依赖文件安装所有依赖：</p>
<pre class="">(snow-venv) $ pip install -r requirements.txt</pre>
<p>如果安装包的时候速度太慢，可以考虑设置 PyPI 国内镜像，具体参考<a href="http://greyli.com/set-custom-pypi-mirror-url-for-pip-pipenv-poetry-and-flit/">这篇文章</a>。</p>
<h2>从其他工具迁移回来</h2>
<p>如果你想从 Pipenv 迁移回来，方法很简单，只需要生成一个 requirements.txt 文件即可。使用下面的命令生成一般依赖列表：</p>
<pre class="">$ pipenv lock -r</pre>
<p>使用下面的命令输出开发依赖列表：</p>
<pre class="">$ pipenv lock -r --dev</pre>
<p>然后手动把两个命令的输出保存为 requirements.txt 和 requirements-dev.txt。</p>
<p><span data-offset-key="571ch-0-0">从 Poetry、Conda 等其他工具迁移回来可以使用 </span><a class="Link ztext-link" href="https://github.com/bndr/pipreqs" target="_blank" rel="noopener" data-offset-key="571ch-1-0" data-editable="true"><span data-offset-key="571ch-1-0">pipreqs</span></a><span data-offset-key="571ch-2-0"> 来生成 requirements.txt，它会基于项目代码的导入语句来生成依赖列表。</span></p>
<p>在下一篇文章，我会介绍一些辅助工具来搭配 virtualenv/venv+pip 使用，让虚拟环境和依赖管理更方便，比如 virtualenvwrapper、pip-tools 等。</p>
<p>（4）</p>
]]></content:encoded>
			<wfw:commentRss>https://greyli.com/back-to-virtualenv-venv-and-pip/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>从国内的 PyPI 镜像（源）安装 Python 包</title>
		<link>https://greyli.com/set-pypi-mirror/</link>
		<comments>https://greyli.com/set-pypi-mirror/#respond</comments>
		<pubDate>Wed, 27 Feb 2019 13:48:52 +0000</pubDate>
		<dc:creator><![CDATA[李辉]]></dc:creator>
				<category><![CDATA[计算机与编程]]></category>
		<category><![CDATA[pip]]></category>
		<category><![CDATA[Pipenv]]></category>
		<category><![CDATA[Poetry]]></category>
		<category><![CDATA[PyPI]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://greyli.com/?p=2365</guid>
		<description><![CDATA[不论是使用 pip，还是 Pipenv、Poetry等工具，安装 Python 包的时候会默认从官方的 PyP [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>不论是使用 pip，还是 Pipenv、Poetry等工具，安装 Python 包的时候会默认从官方的 PyPI 源下载文件，速度比较慢。国内的一些公司和机构提供了 PyPI 镜像源（mirror source），你可以设置让这些工具从国内的镜像源安装 Python 包，以便提高下载速度。</p>
<p>官方 PyPI 源的 URL 为 https://pypi.org/simple （旧的 URL 为 https://pypi.python.org/simple ），下面我们将以豆瓣提供的镜像源为例（URL 为 https://pypi.doubanio.com/simple/），介绍不同工具更改 PyPI 镜像源的方法：</p>
<h2>pip</h2>
<p>临时设置可以通过 -i 选项：</p>
<pre>$ pip install -i https://pypi.doubanio.com/simple/ flask</pre>
<p>全局设置有不同的层级和文件位置，以用户全局（per-user）为例，在 Linux &amp; macOS 中，配置需要写到 ~/.pip/pip.conf 文件中；Windows 中，配置文件位置为 %HOMEPATH%\pip\pip.ini，%HOMEPATH% 即你的用户文件夹，一般为“\Users\&lt;你的用户名&gt;”，具体值可以使用 echo %HOMEPATH% 命令查看。</p>
<p>通常你需要手动创建对应的目录和文件，然后写入下面的内容：</p>
<pre>[global]
index-url = https://pypi.doubanio.com/simple
[install]
trusted-host = pypi.doubanio.com
</pre>
<p>附注：按照 pip 文档，上面的配置文件位置是旧（legacy）的配置方式，但是因为比较方便设置，这里沿用了。新的建议是 Linux &amp; macOS 放到 $HOME/.config/pip/pip.conf，Windows 则放到 %APPDATA%\pip\pip.ini。具体可以访问 <a href="https://pip.pypa.io/en/stable/user_guide/#config-file、">pip 文档配置部分</a>查看。</p>
<h2>Pipenv</h2>
<p>类似 pip 的 -i （&#8211;index-url）选项，你可以使用 &#8211;pypi-mirror 临时设置镜像源地址：</p>
<pre>$ pipenv install --pypi-mirror https://pypi.doubanio.com/simple flask</pre>
<p>如果想对项目全局（per-project）设置，可以修改 Pipfile 中 [[source]] 小节：</p>
<pre>[[source]]

url = "https://pypi.doubanio.com/simple"
verify_ssl = true
name = "douban"</pre>
<p>另外一种方式是使用环境变量 PIPENV_PYPI_MIRROR 设置（Windows 系统使用 set 命令）：</p>
<pre>$ export PIPENV_PYPI_MIRROR=https://pypi.doubanio.com/simple</pre>
<p>你可以通过把这个环境变量的设置语句写入到终端的配置文件里实现“永久”设置，Linux &amp; macOS 可参考<a href="https://unix.stackexchange.com/questions/117467/how-to-permanently-set-environmental-variables">这里</a>，Windows 可参考<a href="https://www.howtogeek.com/51807/how-to-create-and-use-global-system-environment-variables/">这里</a>。</p>
<h2>Poetry / Flit</h2>
<p>因为 Poetry，Flit 这些工具遵循 PEP 518 创建了一个 pyproject.toml 文件来替代 setup.py、Pipfile 等配置文件，所以我们可以在这个文件里更改 PyPI 源。</p>
<p>使用 Poetry 时，在 pyproject.toml 末尾添加下面的内容来设置自定义镜像源：</p>
<pre>[[tool.poetry.source]]
name = "douban"
url = "https://pypi.doubanio.com/simple/"</pre>
<p>目前暂时没有其他方式，未来或许会为 poetry add 命令添加一个相关的设置选项。</p>
<p>同样的，Flit 大概要添加下面这些内容（未测试）：</p>
<pre>[[tool.flit.source]]
name = "douban"
url = "https://pypi.doubanio.com/simple/"</pre>
<h2>常用的国内 PyPI 镜像列表</h2>
<ul>
<li>豆瓣 https://pypi.doubanio.com/simple/</li>
<li>网易 https://mirrors.163.com/pypi/simple/</li>
<li>阿里云 https://mirrors.aliyun.com/pypi/simple/</li>
<li>清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/</li>
</ul>
<p>顺便提一下，使用镜像源需要注意一个问题：包的版本可能不会及时更新，遇到这种情况可以通过临时换回官方源解决。</p>
]]></content:encoded>
			<wfw:commentRss>https://greyli.com/set-pypi-mirror/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pipenv使用时出现TypeError、ResourceWarning、或ImportError错误的解决方法</title>
		<link>https://greyli.com/pipenv-install-got-typeerror-resourcewarning-or-importerror/</link>
		<comments>https://greyli.com/pipenv-install-got-typeerror-resourcewarning-or-importerror/#comments</comments>
		<pubDate>Tue, 09 Oct 2018 04:18:11 +0000</pubDate>
		<dc:creator><![CDATA[李辉]]></dc:creator>
				<category><![CDATA[计算机与编程]]></category>
		<category><![CDATA[pip]]></category>
		<category><![CDATA[Pipenv]]></category>

		<guid isPermaLink="false">http://greyli.com/?p=1953</guid>
		<description><![CDATA[10月16日更新 Pipenv 10.13 据说已经修复所有相关问题，可以尝试更新： $ python3 -m [&#8230;]]]></description>
				<content:encoded><![CDATA[<h2><b>10月16日更新</b></h2>
<p>Pipenv 10.13 据说已经修复所有相关问题，可以尝试更新：</p>
<div>
<pre class="">$ python3 -m pip install --upgrade pip 
$ python3 -m pip install --upgrade pipenv</pre>
</div>
<h2><b>Pipenv 2018.7.1</b></h2>
<p>Pipenv 2018.7.1版本和最新版本的pip不兼容，根据不同的命令和环境，会出现下面的异常：</p>
<ul>
<li>TypeError: &#8216;module&#8217; object is not callable （pipenv install）</li>
<li>ResourceWarning: Implicitly cleaning up &#8230; （pipenv install）</li>
<li>ImportError: cannot import name &#8216;get_installed_distributions&#8217; （pipenv graph）</li>
</ul>
<p>目前可以临时通过降级pip来解决：</p>
<pre class="">$ python3 -m pip install pip==10.0.1</pre>
<p>如果你使用Python2，则使用下面的命令：</p>
<pre class="">$ python -m pip install pip==10.0.1</pre>
<p>相关issue见<a href="https://github.com/pypa/pipenv/issues/2924">#2924</a>、<a href="https://github.com/pypa/pipenv/issues/2925">#2925</a>、<a href="https://github.com/pypa/pipenv/issues/2944">#2944</a>。</p>
<h2><b>Pipenv 2018.10.9</b></h2>
<p>如果使用的是最新的2018.10.9版本，那么在Python 2.7下会出现下列异常：</p>
<ul>
<li>ImportError: No module named weakref</li>
<li>ImportError: No module named shutil_get_terminal_size</li>
</ul>
<p>可以临时通过手动安装这两个库来解决：</p>
<div>
<pre class="">$ pip install backports.weakref backports.shutil_get_terminal_size</pre>
</div>
<h2>Pipenv 修复版本发布后</h2>
<p>等到Pipenv发布新版本修复了这些问题后，可以通过下面的命令升级pipenv和pip：</p>
<pre class="">$ python3 -m pip install --upgrade pip
$ python3 -m pip install --upgrade pipenv</pre>
<p>如果你在阅读<a href="http://helloflask.com/book">《Flask Web开发实战》</a>时还遇到了其他问题，可以先到<a href="https://github.com/greyli/helloflask/blob/master/faq/faq.md">FAQ</a>中查看，没有解决可以在<a href="https://github.com/greyli/helloflask">helloflask仓库</a>创建issue。</p>
]]></content:encoded>
			<wfw:commentRss>https://greyli.com/pipenv-install-got-typeerror-resourcewarning-or-importerror/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
