问题:

我正在阅读和解析Amazon XML文件,而XML文件显示’,当我尝试打印它时,我收到以下错误:

'ascii' codec can't encode character u'\u2019' in position 16: ordinal not in range(128) 

从我到目前为止在线阅读的内容来看,错误来自于XML文件是UTF-8,但Python希望将其作为ASCII编码字符处理。 是否有一种简单的方法可以使错误消失并让我的程序在读取时打印XML?

I’m reading and parsing an Amazon XML file and while the XML file shows a ‘ , when I try to print it I get the following error:From what I’ve read online thus far, the error is coming from the fact that the XML file is in UTF-8, but Python wants to handle it as an ASCII encoded character.Is there a simple way to make the error go away and have my program print the XML as it reads?

问题:

我刚刚安装了matplotlib,并尝试运行其中一个示例脚本。 但是我遇到了下面详述的错误。 我究竟做错了什么?

from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.gca(projection='3d')
X, Y, Z = axes3d.get_test_data(0.05)
cset = ax.contour(X, Y, Z, 16, extend3d=True)
ax.clabel(cset, fontsize=9, inline=1)

plt.show()

错误是

Traceback (most recent call last):
  File "<string>", line 245, in run_nodebug
  File "<module1>", line 5, in <module>
  File "C:\Python26\lib\site-packages\matplotlib\figure.py", line 945, in gca
    return self.add_subplot(111, **kwargs)
  File "C:\Python26\lib\site-packages\matplotlib\figure.py", line 677, in add_subplot
    projection_class = get_projection_class(projection)
  File "C:\Python26\lib\site-packages\matplotlib\projections\__init__.py", line 61, in get_projection_class
    raise ValueError("Unknown projection '%s'" % projection)
ValueError: Unknown projection '3d'

I just installed matplotlib and am trying to run one of there example scripts.However I run into the error detailed below.What am I doing wrong?The error is

问题:

我正在尝试在新的virtualenv中安装matplotlib。

当我做:

pip install matplotlib

要么

pip install http://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-1.1.0/matplotlib-1.1.0.tar.gz

我收到此错误:

building 'matplotlib._png' extension

gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -fPIC -  DPY_ARRAY_UNIQUE_SYMBOL=MPL_ARRAY_API -DPYCXX_ISO_CPP_LIB=1 -I/usr/local/include -I/usr/include -I. -I/home/sam/django-projects/datazone/local/lib/python2.7/site-packages/numpy/core/include -I. -I/usr/include/python2.7 -c src/_png.cpp -o build/temp.linux-x86_64-2.7/src/_png.o

src/_png.cpp:10:20: fatal error: png.h: No such file or directory

compilation terminated.

error: command 'gcc' failed with exit status 1

有人知道发生了什么事吗?

任何帮助非常感谢。

I am trying to install matplotlib in a new virtualenv.When I do:orI get this error:Anyone have an idea what is going on?Any help much appreciated.