<p>问题不在于<code>pip</code>将<code>_</code>转换为<code>-</code>以满足包命名要求,而是:包处于<code>beta</code>状态,没有稳定的包版本。换句话说,只有<a href="https://pypi.python.org/pypi/line_profiler" rel="noreferrer">package PyPI page</a>上的<code>beta</code>包版本链接可用。如您所见,<code>pip</code>看到它:</p>
<pre><code>Could not find a version that satisfies the requirement line-profiler (from versions: 1.0b1, 1.0b2, 1.0b3)
</code></pre>
<p>根据<a href="http://pip.readthedocs.org/en/latest/reference/pip_install.html#pre-release-versions" rel="noreferrer">Pre-release Versions</a>文档页面:</p>
<blockquote>
<p>Starting with v1.4, pip will only install stable versions as specified
by <a href="http://www.python.org/dev/peps/pep-0426" rel="noreferrer">PEP426</a> by default. If a version cannot be parsed as a compliant
<a href="http://www.python.org/dev/peps/pep-0426" rel="noreferrer">PEP426</a> version then it is assumed to be a pre-release.</p>
</blockquote>
<p>将<a href="http://pip.readthedocs.org/en/latest/reference/pip_install.html#install-pre" rel="noreferrer">^{<cd7>}</a>参数传递给<code>pip install</code>:</p>
<blockquote>
<p>--pre </p>
<p>Include pre-release and development versions. By default, pip only finds stable versions.</p>
</blockquote>
<pre><code>sudo pip install --pre line_profiler
</code></pre>
<p>或者,安装特定版本:</p>
<pre><code>sudo pip install line_profiler==1.0b3
</code></pre>