在使用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库.

推荐答案

https://pypi.org/project/saxonche/现在有12.2,应该可以解决问题.

Python-3.x相关问答推荐

Pandas 中每行的最大值范围

使用Python请求从特定URL下载图像时出错

如何定义既允许固定单词又允许模式的pydanti.BaseModel?

PythonPandas 创建一个列并添加到DataFrame

我没有';无法理解此TemplateDoesNotExist错误

为什么不能用格式字符串 '-' 绘制点?

合并所有文件并获取特定列数据

提取图像中的背景并保存

try 使用 GEKKO 求解非线性方程组.系统有多种解决方案,但 GEKKO 给出了错误的解决方案.我该如何解决?

删除给定数组中所有元素为True的所有子数组

以编程方式映射 uniprot ID 时如何解决 400 客户端错误?

Python多进程:运行一个类的多个实例,将所有子进程保留在内存中

如何为 Python 中的线程设置异步事件循环?

__new__ 方法给出错误 object.__new__() 只接受一个参数(要实例化的类型)

使用 pytest.fixture 返回模拟对象的正确方法

django - 值更改后自动更新日期

如何使用python将放置在多个嵌套文件夹中的文档移动和重命名为一个新的单个文件夹?

作为函数对象属性的 __kwdefaults__ 有什么用?

如何将 Matplotlib 图形转换为 PIL Image 对象(不保存图像)

TypeError:无法实例化类型元组;使用 tuple() 代替