从Julia调用Python的内存错误

时间:2016-11-30 13:21:03

标签: python xml julia

我想使用Python包“Beautiful Soup”,但是来自Julia。当我尝试使用Julia包PyCall到达那里时,我得到一个错误。

https://github.com/JuliaPy/PyCall.jl/上的示例对我有用(plt.plot除外)

我执行以下操作:

ENV["PYTHON"]="C:\\Users\\AName\\Anaconda2\\python.exe"
Pkg.build("PyCall")

using PyCall
@pyimport bs4 #need BeautifulSoup
markup=open("c:\\work\\theImData.xml","r")
soup = bs4.BeautifulSoup(PyTextIO(markup),"lxml")

并收到以下回复:

julia> soup = bs4.BeautifulSoup(PyTextIO(markup),"lxml")
ERROR: PyError (:PyObject_Call) <type 'exceptions.MemoryError'>
MemoryError('Julia exception: OutOfMemoryError()',)
  File "C:\Users\AName\Anaconda2\lib\site-packages\bs4\__init__.py", line 191, in __init__
    markup = markup.read()
  File "PyCall.jl", line 1, in <lambda>

 in pyerr_check at C:\Users\AName\.julia\v0.5\PyCall\src\exception.jl:56 [inlined]
 in pyerr_check at C:\Users\AName\.julia\v0.5\PyCall\src\exception.jl:61 [inlined]
 in macro expansion at C:\Users\AName\.julia\v0.5\PyCall\src\exception.jl:81 [inlined]
 in #_pycall#62(::Array{Any,1}, ::Function, ::PyCall.PyObject, ::PyCall.PyObject, ::Vararg{Any,N}) at C:\Users\AName\.julia\v0
.5\PyCall\src\PyCall.jl:546
 in _pycall(::PyCall.PyObject, ::PyCall.PyObject, ::Vararg{Any,N}) at C:\Users\AName\.julia\v0.5\PyCall\src\PyCall.jl:534
 in #pycall#66(::Array{Any,1}, ::Function, ::PyCall.PyObject, ::Type{PyCall.PyAny}, ::PyCall.PyObject, ::Vararg{Any,N}) at C:\Users\B
jornPersson\.julia\v0.5\PyCall\src\PyCall.jl:568
 in pycall(::PyCall.PyObject, ::Type{PyCall.PyAny}, ::PyCall.PyObject, ::Vararg{Any,N}) at C:\Users\AName\.julia\v0.5\PyCall\s
rc\PyCall.jl:568
 in #call#67(::Array{Any,1}, ::PyCall.PyObject, ::PyCall.PyObject, ::Vararg{Any,N}) at C:\Users\AName\.julia\v0.5\PyCall\src\P
yCall.jl:571
 in (::PyCall.PyObject)(::PyCall.PyObject, ::Vararg{Any,N}) at C:\Users\AName\.julia\v0.5\PyCall\src\PyCall.jl:571

为了确保.xml很小,我使用仅包含以下内容的.xml进行测试:

<?xml version="1.0"?>
<FacitData>
	<DirectoryData directory="0028">
		<Image fileName="image_0000911.png" />
	</DirectoryData>
</FacitData>

我是否正确地调用了PyCall?

0 个答案:

没有答案