longcpu 发表于 2022-1-7 16:19:33

关于调用python的方法.

有些简单的python脚本可以运行, 稍微难一点的就会出问题,比如:
PyPrint:ModuleNotFoundError: No module named 'unicodedata'

请问这是什么原因?

longcpu 发表于 2022-1-7 16:27:20

比如说一个很简单的代码:

import multiprocessing
import os, time, random
def Lee():
    print("\nRun task Lee-%s" % (os.getpid()))# os.getpid()获取当前的进程的ID
    start = time.time()
    time.sleep(random.random() * 10)# random.random()随机生成0-1之间的小数
    end = time.time()
    print('Task Lee, runs %0.2f seconds.' % (end - start))

def Marlon():
    print("\nRun task Marlon-%s" % (os.getpid()))
    start = time.time()
    time.sleep(random.random() * 10)
    end = time.time()
    print('Task Marlon runs %0.2f seconds.' % (end - start))

def Allen():
    print("\nRun task Allen-%s" % (os.getpid()))
    start = time.time()
    time.sleep(random.random() * 10)
    end = time.time()
    print('Task Allen runs %0.2f seconds.' % (end - start))

def Frank():
    print("\nRun task Frank-%s" % (os.getpid()))
    start = time.time()
    time.sleep(random.random() * 10)
    end = time.time()
    print('Task Frank runs %0.2f seconds.' % (end - start))

if __name__ == '__main__':
    function_list =
    print("parent process %s" % (os.getpid()))
    pool = multiprocessing.Pool(4)
    for func in function_list:
      pool.apply_async(func)
    print('Waiting for all subprocesses done...')
    pool.close()
    pool.join()
    print('All subprocesses done.')

怎么弄的运行不了

longcpu 发表于 2022-1-7 16:28:54

错误代码为:
PyPrint:Traceback (most recent call last):
PyPrint:File "<string>", line 2, in <module>
PyPrint:File "<frozen zipimport>", line 259, in load_module
PyPrint:File "F:\PTEST\调用PY38\_int\调用PY38\debug\x64\linker\Python3_9.zip\multiprocessing\__init__.py", line 16, in <module>
PyPrint:File "<frozen zipimport>", line 259, in load_module
PyPrint:File "F:\PTEST\调用PY38\_int\调用PY38\debug\x64\linker\Python3_9.zip\multiprocessing\context.py", line 6, in <module>
PyPrint:File "<frozen zipimport>", line 259, in load_module
PyPrint:File "F:\PTEST\调用PY38\_int\调用PY38\debug\x64\linker\Python3_9.zip\multiprocessing\reduction.py", line 16, in <module>
PyPrint:File "<frozen zipimport>", line 259, in load_module
PyPrint:File "F:\PTEST\调用PY38\_int\调用PY38\debug\x64\linker\Python3_9.zip\socket.py", line 51, in <module>
PyPrint:ModuleNotFoundError: No module named '_socket'

play 发表于 2022-3-3 11:53:26

QQ多少?我帮你

ticpro 发表于 2022-3-10 17:44:23

老哥,你解决了吗,请问你用过docxtpl库吗,我用了,ImportError: cannot import name 'etree' from 'lxml'。。。。心态炸裂
页: [1]
查看完整版本: 关于调用python的方法.