在使用Python3.11.2创建的全新虚拟环境中运行Windows10
python -m venv effnve
我激活了VE然后做了
pip install saxonche
根据萨克松奇的homepage分.
每当我现在启动python时,我都会得到:
Error processing line 1 of C:\ff\effnve\Lib\site-packages\_preload_saxonche_12.1.0.pth:
Traceback (most recent call last):
File "<frozen site>", line 186, in addpackage
File "<string>", line 1, in <module>
File "<string>", line 18, in <module>
FileNotFoundError: .load-order-saxonche-12.1.0 not found
Remainder of file ignored
文件.load-order-saxonche-12.1.0
就在C:\ff\effnve\Lib\site-packages
中
我试着调整到_preload_saxonche_12.1.0.pth
,但没有用.为了完整起见,这里是我在 comments 中指定的调整.
import sys; exec("
import ctypes
import os
import site
is_pyinstaller = getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS')
for d in site.getsitepackages():
# the above line will retrieve ['C:\ff\effnve', 'C:\ff\effnve\Lib\site-packages']
# so it'll always fall down the else-clause, hence
# tweak 1: start only if you have a path with site-packages
if 'site-packages' in d:
load_order_filepath = os.path.join(d, '.load-order-saxonche-12.1.0')
if os.path.isfile(load_order_filepath):
with open(load_order_filepath) as file:
load_order = file.read().split()
for lib in load_order:
lib_path = os.path.join(d, lib)
if not is_pyinstaller or os.path.isfile(lib_path):
ctypes.WinDLL(lib_path)
print(ctypes.WinDLL(lib_path)) # tweak: check it loads all 3 dll's.
# break # tweak: this break was originally 8 eight spaces from start of line. Why?
# # Do you only need the first dll? Don't understand.
else: # tweak: this else was originally at the start of the line. Why?
if not is_pyinstaller:
raise FileNotFoundError('.load-order-saxonche-12.1.0' + ' not found')
print(d) # tweak to find out what it did not find.
")
我会把它作为一个问题发布在GitHub或类似的地方,但我找不到其他地方分享它,这就是我在这里发布它的原因.
之所以使用saxonche
,是因为我需要一个支持XSLT 2.0的Python库.