在Python 3.6上使用brew安装pipenv

6

我想使用Homebrew安装pipenv,参见这里

首先,我运行了$ brew install pipenv。然后,brew自动安装了Python 3.7,并且我可以正常使用pipenv。但是,我想在Python 3.6上使用pipenv,所以我运行了$ brew switch python 3.7 3.6.5,然后当我尝试$ pipenv install时,会出现以下错误:

dyld: Library not loaded: @executable_path/../.Python
  Referenced from: /usr/local/Cellar/pipenv/2018.11.26/libexec/bin/python3.7
  Reason: image not found
Abort trap: 6

有没有办法在Python 3.6.5上安装pipenv呢?
谢谢。

你可以始终使用pip安装到您特定的Python环境。 - Prayson W. Daniel
5个回答

7
我曾经遇到过同样的问题,花了很长时间进行研究。最终我发现我的项目并不一定需要使用python3.6,因此我将brew切换至 python3.7 并重新安装了 pipenv
如果你必须使用 python3.6 来使用 pipenv,那么你可能会发现这个线程有所帮助,但对我来说,它似乎是一种核选项,我不想走这条路。
如何回退到使用 python3.7 接着使用 pipenv:
# get your version of python3.7
brew list --versions python

# switch to your python3.7 version
brew switch python 3.7.x_x 

# install pipenv if it was removed during the troubleshooting process
brew install pipenv

# pipenv should work now
pipenv --help

2

尝试以下操作,但首先需要安装Python 3.6.5版本。

pipenv --python 3.6.5

这是唯一有效的解决方案,我的情况是 "pipenv install" 引发了上述错误,似乎 pipeline 的目标是错误的 Python 框架。 - 0xFK

1

您可以始终使用pip安装特定的Python版本:

python3 -m pip install --user pipenv

这里假设你使用的是Python3.6.5版本,如果不是,请使用你想要的Python完整路径。


1

https://github.com/pypa/pipenv/issues/2965

确保使用的是Python3.6版本

$ python
Python 3.6.5 (default, Jun 17 2018, 12:13:06)
[GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>

$ brew switch python # if not, see your versions
Error: Usage: brew switch <formula> <version>
python installed versions: 3.6.5_1, 3.7.3

$ brew switch python 3.6.5_1 # change your version if is necessary
Cleaning /usr/local/Cellar/python/3.6.5_1
Cleaning /usr/local/Cellar/python/3.7.3
25 links created for /usr/local/Cellar/python/3.6.5_1

安装pipenv 2018.6.25。
$ brew unlink pipenv
$ brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/2c0bbfa297e2429cd6e080ad5231f3aa56ff4f65/Formula/pipenv.rb

更改为 pipenv 2018.6.25

$ brew switch pipenv 2018.6.25

0

在升级OSX版本后遇到了同样的问题。

通过卸载homebrew安装并按照"实用安装"说明解决:

brew uninstall pipenv
pip install --user pipenv

如果你遇到了 pipenv: command not found 的问题,按照说明将用户基础二进制目录添加到你的 PATH 中。对于 OSX 用户,请在你的 ~/.bash_profile 文件中添加以下内容:
export PATH=/Users/YOUR_USER_NAME/.local/bin:$PATH

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接