Python Matplotlib 版本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21473600/
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
Matplotlib Version
提问by Jared
Having my system prepped with homebrew and using pip install matplotlibafter successful installation of numpy and scipy, I'm getting a successful installation. Then, running
让我的系统准备好自制软件并pip install matplotlib在成功安装 numpy 和 scipy 后使用,我安装成功。然后,运行
$ python
Python 2.7.6 (default, Jan 30 2014, 20:19:23)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.79)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
>>> matplotlib.__version__
'1.1.1'
This is a very outdated version and noone of my programs run with it. I used pip uninstall matplotliband redid it with pip install 'the url for 1.3.1'and it still reads version 1.1.1. Is there a way I can manually delete all python libraries, even python itself, and restart from scratch? Or is this an obvious fix for this?
这是一个非常过时的版本,我的任何程序都没有运行它。我使用pip uninstall matplotlib并重做它,pip install 'the url for 1.3.1'它仍然读取版本 1.1.1。有没有办法可以手动删除所有 python 库,甚至 python 本身,然后从头开始?或者这是一个明显的解决方法?
EDIT: I'm running Mac OS X version 10.9. I just reinstalled python 2.7 with scipy, numpy, and matplotlib through macports. Is there a very basic way to see where, when I import matplotlibfrom the python environment, it is calling it from? Like whichin the terminal? I began using homebrew but switched to macports for more control. Can that be a problem? Do I need to completely remove homebrew?
编辑:我正在运行 Mac OS X 10.9 版。我刚刚通过 macports 用 scipy、numpy 和 matplotlib 重新安装了 python 2.7。有没有一种非常基本的方法可以查看当我import matplotlib从 python 环境调用它时的位置?比如which在终端?我开始使用自制软件,但切换到 macports 以获得更多控制。这可能是个问题吗?我需要完全删除自制软件吗?
I did get this message at first:
Warning: Error parsing file /Applications/MacPorts/Python 2.7/Python Launcher.app/Contents/MacOS/Python Launcher: Error opening or reading filebut after running $ sudo port -f deactivate python27followed by sudo port activate python27I no longer have that warning, but I wanted to include this detail for completeness.
我一开始确实收到了这条消息:
Warning: Error parsing file /Applications/MacPorts/Python 2.7/Python Launcher.app/Contents/MacOS/Python Launcher: Error opening or reading file但是在运行$ sudo port -f deactivate python27之后sudo port activate python27我不再有那个警告,但我想包括这个细节以保持完整性。
EDIT 2: Could some things be installing to opt/local/binwhen they need to be installed to usr/local/bin?
编辑 2:某些东西可以opt/local/bin在需要安装到时安装到usr/local/bin吗?
EDIT 3: To shed some light on this, print scipy.__version__reads 0.11.0which is several outdated, print numpy.__version__reads 1.6.2which is also outdated. However I attempt to install says the installation was successful, which I don't doubt. I suspect it's not linked up together in a correct way. Is there a way delete everything that is connected to python at all and restart?
编辑 3:为了说明这一点,print scipy.__version__阅读0.11.0了几个过时的内容,print numpy.__version__阅读了1.6.2也过时的内容。但是我尝试安装说安装成功,我不怀疑。我怀疑它没有以正确的方式连接在一起。有没有办法删除连接到python的所有内容并重新启动?
FINAL EDIT: I think the easiest way to handle this is to run which pythonand see what options you have to run python. Because I used homebrew and macports at this time (not recommended) I had four options- a macports install, a package install from python.org, a homebrew install, and the standard 2.6 from Apple. Iterate through these and find which one your installer (pipor easy_install) is placing your frameworks and run that python when you need certain dependencies. The best way is use only one package manager and run virtual environments if you need different dependencies, but we're all learning as we go.
最终编辑:我认为处理这个问题的最简单方法是运行which python并查看运行 python 的选项。因为我此时使用 homebrew 和 macports(不推荐)我有四个选项 - macports 安装、python.org 的包安装、homebrew 安装和 Apple 的标准 2.6。遍历这些并找到您的安装程序(pip或easy_install)正在放置您的框架并在您需要某些依赖项时运行该 python。如果您需要不同的依赖项,最好的方法是只使用一个包管理器并运行虚拟环境,但我们都在学习。
采纳答案by Jared
The problem was with the $PATHvariable. Instead of changing something in that variable, I uninstalled all packages in ./Library/Frameworks/. Either way would work. When I was getting that my current version was '1.1.1', that was the current version for the standard python installed on Mac, which is version 2.6, when I was updating with all of the current libraries for 2.7.
问题出在$PATH变量上。我没有更改该变量中的某些内容,而是卸载了./Library/Frameworks/. 无论哪种方式都会起作用。当我得知我的当前版本是 时'1.1.1',这是 Mac 上安装的标准 python 的当前版本,即 2.6 版,当时我正在使用 2.7 的所有当前库进行更新。
NOTE: When uninstalling the frameworks, do not uninstall 2.6 however because the preinstalled mac build is used for a lot of other Mac programs, and I ended up having to reinstall my OS.
注意:卸载框架时,请不要卸载 2.6,因为预装的 mac 版本用于许多其他 Mac 程序,我最终不得不重新安装操作系统。
回答by phyrox
Using Matplotlib in OSX can give you problems. In this page, they say:
在 OSX 中使用 Matplotlib 会给你带来问题。在这个页面,他们说:
The build situation on OSX is complicated by the various places one can get the libpng and freetype requirements (darwinports, fink, /usr/X11R6) and the different architectures (e.g., x86, ppc, universal) and the different OSX version (e.g., 10.4 and 10.5).
OSX 上的构建情况很复杂,因为可以在不同地方获得 libpng 和 freetype 要求(darwinports、fink、/usr/X11R6)以及不同的体系结构(例如 x86、ppc、universal)和不同的 OSX 版本(例如, 10.4 和 10.5)。
In the official page of Matplotlib they recommend to use the mkpg installer:
在 Matplotlib 的官方页面中,他们建议使用 mkpg 安装程序:
The mkpg installer will have a “zip” extension, and will have a name like matplotlib-1.2.0-py2.7-macosx10.5_mpkg.zip. The name of the installer depends on which versions of python, matplotlib, and OSX it was built for. [...] install to a directory like /Library/Python/2.7/site-packages/ (exact path depends on your python version).
mkpg 安装程序将有一个“zip”扩展名,名称类似于 matplotlib-1.2.0-py2.7-macosx10.5_mpkg.zip。安装程序的名称取决于它是为哪个版本的 python、matplotlib 和 OSX 构建的。[...] 安装到 /Library/Python/2.7/site-packages/ 之类的目录(确切路径取决于您的 Python 版本)。
In the OSX-Notes Sectionyou have more information about this installing.
在OSX-Notes 部分,您有关于此安装的更多信息。
Edited:
编辑:
I haven't found any MPKG but you can use thisDMG.
我没有找到任何 MPKG 但你可以使用这个DMG。
回答by Colin Bernet
If you install yolk, you can see with
如果你安装蛋黄,你可以看到
yolk -V matplotlib
that version 1.3.1 of matplotlib is available. But pip won't let you install it because it is managed externally. The solution is to do:
matplotlib 的 1.3.1 版本可用。但是 pip 不允许您安装它,因为它是由外部管理的。解决办法是这样做:
pip install -Iv https://downloads.sourceforge.net/project/matplotlib/matplotlib/matplotlib-1.3.1/matplotlib-1.3.1.tar.gz
At first it didn't work for me though because of a problem with true type fonts. but I just had to google for the error message to find the solution on stackoverflow, which is to do the following before installing matplotlib:
起初它对我不起作用,因为真正的字体有问题。但我只需要谷歌搜索错误消息即可在stackoverflow上找到解决方案,这是在安装matplotlib之前执行以下操作:
ln -s /usr/local/opt/freetype/include/freetype2 /usr/local/include/freetype
回答by dianei
I had this error as well.
我也有这个错误。
A simple change of ~/.profile or ~/.bash_profile of the path order fixed it. Before it was looking in /usr/bin first and not where things had been linked with homebrew.
路径顺序的 ~/.profile 或 ~/.bash_profile 的简单更改修复了它。在它首先查看 /usr/bin 而不是与自制软件相关联的地方之前。
export PATH=/usr/local/bin:$PATH
回答by Akash Kandpal
Copy-Paste the following code in your terminal and press enter , it will show the version of matplotlib installed on your system ::
将以下代码复制粘贴到您的终端中并按 Enter 键,它将显示您系统上安装的 matplotlib 版本 ::
python
import matplotlib
print('matplotlib: {}'.format(matplotlib.__version__))

