问题描述
我运行包含熊猫Python脚本(一个导致问题)库我得到这个错误:
I run the python script that contain Pandas (that one cause the problem) library I got this error:
Traceback (most recent call last):
File "test.py", line 2, in <module>
import pandas
ImportError: No module named pandas
但是,如果我从包路径导入,以确保它检测到大熊猫库,我得到这个错误讯息
But if I import from package path to make sure it detects Pandas library, I got this error message
Traceback (most recent call last):
File "test.py", line 3, in <module>
import pandas
File "/usr/local/lib/python2.7/site-packages/pandas/__init__.py", line 44, in <module>
from pandas.core.api import *
File "/usr/local/lib/python2.7/site-packages/pandas/core/api.py", line 9, in <module>
from pandas.core.groupby import Grouper
File "/usr/local/lib/python2.7/site-packages/pandas/core/groupby.py", line 16, in <module>
from pandas.core.frame import DataFrame
File "/usr/local/lib/python2.7/site-packages/pandas/core/frame.py", line 41, in <module>
from pandas.core.series import Series
File "/usr/local/lib/python2.7/site-packages/pandas/core/series.py", line 2864, in <module>
import pandas.tools.plotting as _gfx
File "/usr/local/lib/python2.7/site-packages/pandas/tools/plotting.py", line 28, in <module>
import pandas.tseries.converter as conv
File "/usr/local/lib/python2.7/site-packages/pandas/tseries/converter.py", line 7, in <module>
import matplotlib.units as units
File "/usr/local/lib/python2.7/site-packages/matplotlib/__init__.py", line 1131, in <module>
rcParams = rc_params()
File "/usr/local/lib/python2.7/site-packages/matplotlib/__init__.py", line 975, in rc_params
return rc_params_from_file(fname, fail_on_error)
File "/usr/local/lib/python2.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 "/usr/local/lib/python2.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 "/usr/local/lib/python2.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 543, in getdefaultlocale
return _parse_localename(localename)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 475, in _parse_localename
raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: UTF-8
我已经更新我的的.bash_profile
和的.bashrc
与这些线,但仍无法正常工作,甚至我已经重新启动终端与我的机器。
I already update my .bash_profile
and .bashrc
with these lines but still not working even I already restart the terminal and my machine.
export LANG="it_IT.UTF-8"
export LC_COLLATE="it_IT.UTF-8"
export LC_CTYPE="it_IT.UTF-8"
export LC_MESSAGES="it_IT.UTF-8"
export LC_MONETARY="it_IT.UTF-8"
export LC_NUMERIC="it_IT.UTF-8"
export LC_TIME="it_IT.UTF-8"
export LC_ALL="it_IT.UTF-8"
我也启用了终端preferences启动 设置语言环境变量。
I'm also enabled Set locale environment variables on startup
in the terminal preferences.
我怕造成的,因为EI Capitan的问题。请指教。谢谢你。
I'm afraid the problem caused because of EI Capitan. Please advise. Thank you.
推荐答案
修改:熊猫,它的相关性,有的这是在非C语言环境中发现并修复在最新版本。
Edit: Pandas, and its dependencies, had localization bugs that were discovered in non-C locales and fixed in recent versions.
当我通过下载最新版本的熊猫到一个OS X计算机的优胜美地sudo的点子中设置为it_IT.UTF-8的终端安装熊猫
,然后导入它在一个新的Python会话,我是不是能够重现这个问题。
When I downloaded the latest version of Pandas onto an OS X Yosemite computer via sudo pip install pandas
in a terminal set to it_IT.UTF-8, and then imported it in a new Python session, I wasn't able to reproduce this issue.
我最好的猜测现在 - 我想强调这只是一种猜测 - 是大熊猫在该文件夹predates版本的修复和it_IT.UTF-8被打破。 (我认为这是,权衡利弊,较发行是具体到埃尔卡皮坦的可能性更大。)
My best guess now - and I'd emphasize this is only a guess - is that the version of Pandas in that folder predates those fixes and is broken in it_IT.UTF-8. (I do think this is, on balance, more likely than the issue being specific to El Capitan.)
这篇关于蟒蛇 - ValueError错误:未知区域:UTF-8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!