我想在Mac(10.7.5 Lion)中安裝Matplotlib,其中python(2.7.1),pip(8.1.2),numpy(1.11.0),astropy(1.2)已經安裝並正在工作如預期。首先,我試着用命令安裝Matplotlib
sudo pip install matpltlib
,它表明Matplotlib 1.5.1已成功安裝。但是,當我進入蟒蛇和類型import matplotlib
這表明這樣的錯誤消息:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/matplotlib/__init__.py", line 1131, in <module>
rcParams = rc_params()
File "/Library/Python/2.7/site-packages/matplotlib/__init__.py", line 975, in rc_params
return rc_params_from_file(fname, fail_on_error)
File "/Library/Python/2.7/site-packages/matplotlib/__init__.py", line 1100, in rc_params_from_file
config_from_file = _rc_params_in_file(fname, fail_on_error)
File "/Library/Python/2.7/site-packages/matplotlib/__init__.py", line 1018, in _rc_params_in_file
with _open_file_or_url(fname) as fd:
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/contextlib.py", line 17, in __enter__
return self.gen.next()
File "/Library/Python/2.7/site-packages/matplotlib/__init__.py", line 1000, in _open_file_or_url
encoding = locale.getdefaultlocale()[1]
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 496, in getdefaultlocale
return _parse_localename(localename)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 428, in _parse_localename
raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: UTF-8
我不明白,究竟是什麼問題。我打開了所有這些.py文件,並且已經讀取了指定行中的命令。由於這些是隻讀文件(甚至是根目錄),因此無法編輯任何內容。我不知道如何解決這個問題。
好吧,我再由PIP卸載它,並試圖從source.When安裝我嘗試(下載280 MB的源文件後)通過python setup.py build
打造它,它最終將幾個錯誤,如這個 -
src/_macosx.m:2494: warning: implicit conversion shortens 64-bit value into a 32-bit value
src/_macosx.m:1337: error: ‘for’ loop initial declaration used outside C99 mode
lipo: can't open input file: /var/folders/ks/31hhg2hj3273tbk2xwbjfv2h0000gn/T//ccEOsZZ4.out (No such file or directory)
lipo: can't open input file: /var/tmp//ccLauouU.out (No such file or directory)
error: command 'llvm-gcc-4.2' failed with exit status 1
我查過了,沒有名爲var的目錄。我無法調試這個了。
命令'locale'(在你的終端中,不是Python)產生了什麼?您似乎具有無效的區域設置配置。 –
它產生 「LANG = LC_COLLATE =」 C 「 LC_CTYPE = 」UTF-8「 LC_MESSAGES = 」C「 LC_MONETARY = 」C「 LC_NUMERIC = 」C「 LC_TIME = 」C「 LC_ALL = 」 – Sanskriti
注意你的'LC_CTYPE'變量;應該將語言環境變量設置爲語言代碼,再加上一個點和一個字符集。將它設置爲'LC_CTYPE =「en_US.UTF-8」';你可能想找到它的位置。 –