仍然找到安装了pyenv的系统python-安装模块

时间:2020-07-20 10:38:30

标签: python python-3.x module pyenv

在Mac(当前操作系统)上,系统python仍为2.7。我已经安装了pyenv,并成功安装了3.7.3。

dandonaldson@Dans-MacBook-Pro-2 gpt-2 % pyenv local
3.7.3
dandonaldson@Dans-MacBook-Pro-2 gpt-2 % pyenv global
3.7.3
dandonaldson@Dans-MacBook-Pro-2 gpt-2 % 

如果我现在尝试安装pipx作为安装软件包的方式,我会得到

dandonaldson@Dans-MacBook-Pro-2 gpt-2 % pip install --user pipx 
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Collecting pipx
  Using cached pipx-0.15.4.0.tar.gz (336 kB)
    ERROR: Command errored out with exit status 1:
     command: /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/fz/hkppw37x1tz20d3jv8rb3vmr0000gn/T/pip-install-u0WjuX/pipx/setup.py'"'"'; __file__='"'"'/private/var/folders/fz/hkppw37x1tz20d3jv8rb3vmr0000gn/T/pip-install-u0WjuX/pipx/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 /private/var/folders/fz/hkppw37x1tz20d3jv8rb3vmr0000gn/T/pip-pip-egg-info-bKDh7q
         cwd: /private/var/folders/fz/hkppw37x1tz20d3jv8rb3vmr0000gn/T/pip-install-u0WjuX/pipx/
    Complete output (1 lines):
    Python 3.6 or later is required. See https://github.com/pipxproject/pipx for installation instructions.
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

有人告诉我不要在* / Frameworks中删除python,所以看来我必须在解决该问题的同时将其保留在原处。

上次使用Brew拍摄的照片让我留下了

    which python
    python: aliased to /usr/local/bin/python3.8

and when I try this I get

brew uninstall python
Error: Refusing to uninstall /usr/local/Cellar/python@3.8/3.8.4
because it is required by imagemagick, which is currently installed.
You can override this and force removal with:
  brew uninstall --ignore-dependencies python

所以,...

  • 我可以在世界不终结的情况下卸载brew python吗?我没有python项目
  • 我如何才能将模块软件包默认安装在3.7.3可以访问的地方?

我使用rubyenv已经很多年了,这不是可悲的……:(

要点:Python和pyenv是否具有允许python环境拥有自己的模块和版本的相同行为?

1 个答案:

答案 0 :(得分:0)

我的处境与您类似。您是否尝试通过添加以下几行来编辑.zshrc(或.bashrc.bash_profile)?

PATH_TO_PYTHON=/your/3.8/python/directory
export PATH="PATH_TO_PYTHON/bin:$PATH"

这应该添加到您的$PATH目录的开头。这样,当您运行python命令时,将从环境变量$PATH的顶层目录中搜索该命令。因此,如果您最先使用pyenv(即your/root/pyenv/shims),则会在找到系统python(Mac上预装的python)之前在该目录中搜索并找到python。