0

実行ごとにクリーンなインタープリターを使用するために、C++ 組み込み Python エディターにサブインタープリターを追加しました。

  PyThreadState* tmpstate = Py_NewInterpreter();
  PyThreadState_Swap(tmpstate);
  ... run the script ...
  Py_EndInterpreter(tmpstate);

私自身のモジュールは動作しており、問題なく numpy をテストしました。問題はmatplotlibにあります

初めてそれを実行すると、すべてがうまく見えます。二度目に私が得る:

<class 'TypeError'>: attribute of type 'NoneType' is not callable:   File "<string>", line 1, in <module>

  File "C:\Python33\lib\site-packages\pylab.py", line 1, in <module>
from matplotlib.pylab import *

  File "C:\Python33\lib\site-packages\matplotlib\__init__.py", line 152, in <module>
from matplotlib.rcsetup import (defaultParams,

  File "C:\Python33\lib\site-packages\matplotlib\rcsetup.py", line 19, in <module>
from matplotlib.fontconfig_pattern import parse_fontconfig_pattern

  File "C:\Python33\lib\site-packages\matplotlib\fontconfig_pattern.py", line 25, in <module>
from matplotlib.pyparsing_py3 import Literal, ZeroOrMore, \

  File "C:\Python33\lib\site-packages\matplotlib\pyparsing_py3.py", line 3275, in <module>
_escapedHexChar = Combine( Suppress(_bslash + "0x") + Word(hexnums) ).setParseAction(lambda s,l,t:unichr(int(t[0],16)))

   File "C:\Python33\lib\site-packages\matplotlib\pyparsing_py3.py", line 2961, in __init__
self.leaveWhitespace()

File "C:\Python33\lib\site-packages\matplotlib\pyparsing_py3.py", line 2587, in      leaveWhitespace
self.expr = self.expr.copy()

  File "C:\Python33\lib\site-packages\matplotlib\pyparsing_py3.py", line 705, in copy
cpy = copy.copy( self )

  File "C:\Python33\lib\copy.py", line 89, in copy
rv = reductor(2)
4

1 に答える 1

0

これは Python 3.3 のバグのようです: http://bugs.python.org/issue17408

問題は :

The reason is in Objects/typeobject.c: import_copyreg() has a static cache of the copyreg      module.
When the interpreter stops, the module is filled with None... but gets reused in the next     instance.

Resetting this "mod_copyreg" variable to NULL fixes the issue.
pickle is also broken for the same reason.
于 2013-04-15T02:16:51.640 に答える