打包的python lib`site`与pythonn一起失败

2024-05-29 05:46:25 发布

您现在位置:Python中文网/ 问答频道 /正文

似乎导入^{}clr与标准库^{}不兼容

  • 这是clr还是site的问题?你知道吗

NBsite.abs__file__()site.main()调用

In [1]: import site
   ...: site.abs__file__()
   ...:

In [2]: import clr

In [3]: site.abs__file__()
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-3-17ed7fe71c4c> in <module>()
----> 1 site.abs__file__()

C:\Users\mcfarlal\AppData\Local\Continuum\Anaconda2\lib\site.pyc in abs__file__()
     92             continue   # don't mess with a PEP 302-supplied __file__
     93         try:
---> 94             m.__file__ = os.path.abspath(m.__file__)
     95         except (AttributeError, OSError):
     96             pass

TypeError: type does not support setting attribute

调试

如果我们研究函数site.abs__file__,那么失败的恰恰是以下几点:

import os
import sys
clr.__file__ = os.path.abspath(m.__file__)

Tags: pathinimport标准osmainsiteabs

热门问题