pandas 如何在 Mac OS X Sierra 上删除额外的蟒蛇

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/41453961/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 02:42:59  来源:igfitidea点击:

How to delete extra pythons on Mac OS X Sierra

pythonpandas

提问by Noah

In the usr/bin folder, there are three versions of Pythons installed: Python, Python2.6, Python2.7 (the folder names) - not sure what version is for Python folder.

在 usr/bin 文件夹中,安装了三个版本的 Python:Python、Python2.6、Python2.7(文件夹名称)-不确定 Python 文件夹的版本。

My issue, originally, was that I tried to install the module 'pandas' to run a script, python keeps telling me pandas could not be found.

我的问题最初是我试图安装模块 'pandas' 来运行脚本,python 一直告诉我找不到 pandas。

'pip freeze' shows me pandas is already installed. However, I could not find pandas using python>>help>>modules.

'pip freeze' 显示已经安装了 pandas。但是,我无法使用 python>>help>>modules 找到Pandas。

So I suspected there are multiple pythons installed causing pip installing for one of them, but the default python is a different one.

所以我怀疑安装了多个 python,导致其中一个安装了 pip,但默认的 python 是不同的。

So my questions are - 1 Which python is the default one that comes with macOS Sierra? (I can confirm pandas currently is installed for Python, not Python2.6 or Python2.7) 2 Can I remove extra Pythons that do not have pandas? 3 How can I find what it the default Python when I type 'Python...' and how to install pandas for that python?

所以我的问题是 - 1 哪个 python 是 macOS Sierra 附带的默认 python?(我可以确认当前为 Python 安装了 Pandas,而不是 Python2.6 或 Python2.7) 2 我可以删除没有 Pandas 的额外 Pythons 吗?3 当我输入“Python...”以及如何为该python安装pandas时,如何找到默认的Python?

Solved: Thanks for the comments and reply. I used "python2.7 install pip" to install pip for python2.7. Then I used command 'pip2.7 install pandas'. This way, pandas is installed for the default python. (The command 'pip install pandas' on my machine, is installing for python 2.6.)

已解决:感谢您的评论和回复。我使用“python2.7 install pip”为python2.7安装pip。然后我使用命令'pip2.7 install pandas'。这样,pandas 是为默认 python 安装的。(我机器上的命令“pip install pandas”是为 python 2.6 安装的。)

回答by Muntaser Ahmed

  1. macOS Sierra uses Python 2.7 by default.
  2. You can uninstall a version of Python as described here. However, you shouldn't need to as long as you are managing your packages and environments. If you want to maintain more control over your projects and their packages/versions, you should take a look at virtualenv. Virtualenv creates environments that have their own installation directories that don't share packages with other virtualenv environments. This is a very popular option many people use when managing projects.
  3. You can use pip --versionto see which version of Python you are installing a package for. You can also use pip listto see which packages are currently installed.
  1. macOS Sierra 默认使用 Python 2.7。
  2. 您可以按照此处所述卸载 Python 版本。但是,只要您正在管理包和环境,就不需要这样做。如果你想对你的项目及其包/版本保持更多的控制,你应该看看virtualenv。Virtualenv 创建的环境有自己的安装目录,这些目录不与其他 virtualenv 环境共享包。这是许多人在管理项目时使用的一个非常流行的选项。
  3. 您可以使用pip --version来查看要为其安装包的 Python 版本。您还可以使用pip list查看当前安装了哪些软件包。

I highly recommend taking a look at virtualenv as it'll make keeping track of Python environments and their respective packages a lot easier.

我强烈建议您查看 virtualenv,因为它可以更轻松地跟踪 Python 环境及其各自的包。

Hope this helps!

希望这可以帮助!