我正在尝试使用pyximport,如下所示:
import pyximport; pyximport.install(pyimport=True,language_level=3)
from multiprocessing import Pool, Manager, cpu_count
当我尝试运行它时,出现以下错误消息:
Traceback (most recent call last):
File "C:\Python\lib\site-packages\pyximport\pyximport.py", line 216, in load_module
mod = imp.load_dynamic(name, so_path)
File "C:\Python\lib\imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: DLL load failed: %1: not a valid Win32 application.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:/Google drive/Python/Backtesting/backtesting_uj/scratch3.py", line 2, in <module>
from multiprocessing import Pool, Manager, cpu_count
File "C:\Python\lib\site-packages\pyximport\pyximport.py", line 423, in load_module
return load_module(fullname, source_path, so_path=so_path, is_package=is_package)
File "C:\Python\lib\site-packages\pyximport\pyximport.py", line 231, in load_module
raise exc.with_traceback(tb)
File "C:\Python\lib\site-packages\pyximport\pyximport.py", line 216, in load_module
mod = imp.load_dynamic(name, so_path)
File "C:\Python\lib\imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: Building module multiprocessing failed: ['ImportError: DLL load failed: %1: not a valid Win32 application.\n']
任何想法如何解决?我要使用的功能使用multiprocessing Manager dict。 如果仅在导入函数之前放入“ import pyximport; pyximport.install(pyimport = True,language_level = 3)”,则会出现以下错误,因此,我认为必须对整个mulptiprocessing模糊进行cythonized处理。我不是python专家,我正在尝试尽可能加快我的代码的速度。
Traceback (most recent call last):
File "D:/Google drive/Python/Backtesting/backtesting_uj/backtesting_flys_uj_pandas.py", line 100, in <module>
main()
File "D:/Google drive/Python/Backtesting/backtesting_uj/backtesting_flys_uj_pandas.py", line 62, in main
progress_dict = Manager().dict()
File "C:\Python\lib\multiprocessing\context.py", line 56, in Manager
m.start()
File "managers.py", line 543, in multiprocessing.managers.BaseManager.start
File "C:\Python\lib\multiprocessing\process.py", line 112, in start
self._popen = self._Popen(self)
File "C:\Python\lib\multiprocessing\context.py", line 322, in _Popen
return Popen(process_obj)
File "popen_spawn_win32.py", line 67, in multiprocessing.popen_spawn_win32.Popen.__init__
File "popen_spawn_win32.py", line 89, in multiprocessing.popen_spawn_win32.Popen.__init__
File "C:\Python\lib\multiprocessing\reduction.py", line 60, in dump
ForkingPickler(file, protocol).dump(obj)
_pickle.PicklingError: Can't pickle <class 'importlib._bootstrap.DictProxy'>: attribute lookup DictProxy on importlib._bootstrap failed