python - 无法从“asyncio”导入名称“get_running_loop”
问题描述
有一个简单的脚本
# -*- coding: utf-8 -*-
import xlwings as xw
import pandas as pd
wb = xw.Book('Excel_Python-1.xlsx')
data_excel = wb.sheets['Данные']
data_pd = data_excel.range('A1:C4').options(pd.DataFrame, header = 1, index = False).value
print(data_pd)
启动时出错:无法从“asyncio”导入名称“get_running_loop”
检查 'get_running_loop' 方法是否在来自 'asyncio' 的 events.py 模块中。可能是什么问题呢?
"C:\Program Files\Python_370\python.exe" O:/___Python/__Examples/Excel/excel-1.py
Traceback (most recent call last):
File "O:/___Python/__Examples/Excel/excel-1.py", line 2, in <module>
import xlwings as xw
File "C:\Program Files\Python_370\lib\site-packages\xlwings\__init__.py", line 38, in <module>
from .udfs import xlfunc as func, xlsub as sub, xlret as ret, xlarg as arg, get_udf_module, import_udfs
File "C:\Program Files\Python_370\lib\site-packages\xlwings\udfs.py", line 4, in <module>
from asyncio import get_running_loop
ImportError: cannot import name 'get_running_loop' from 'asyncio' (C:\Program Files\Python_370\lib\asyncio\__init__.py)
我以交互方式运行脚本。结果如下:
C:\Windows\system32>python
Python 3.7.0a1 (v3.7.0a1:8f51bb4, Sep 19 2017, 19:32:44) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> # -*- coding: utf-8 -*-
... import xlwings as xw
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
File "C:\Program Files\Python_370\lib\site-packages\xlwings\__init__.py", line 38, in <module>
from .udfs import xlfunc as func, xlsub as sub, xlret as ret, xlarg as arg, get_udf_module, import_udfs
File "C:\Program Files\Python_370\lib\site-packages\xlwings\udfs.py", line 4, in <module>
from asyncio import get_running_loop
ImportError: cannot import name 'get_running_loop' from 'asyncio' (C:\Program Files\Python_370\lib\asyncio\__init__.py)
>>> import pandas as pd
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Program Files\Python_370\lib\site-packages\pandas\__init__.py", line 17, in <module>
"Unable to import required dependencies:\n" + "\n".join(missing_dependencies)
ImportError: Unable to import required dependencies:
numpy:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
* The Python version is: Python3.7 from "C:\Program Files\Python_370\python.exe"
* The NumPy version is: "1.20.1"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: No module named 'numpy.core._multiarray_umath'
>>>
>>> wb = xw.Book('Excel_Python-1.xlsx')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'xw' is not defined
>>> data_excel = wb.sheets['Данные']
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'wb' is not defined
>>> data_pd = data_excel.range('A1:C4').options(
... pd.DataFrame, header = 1, index = False).value
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'data_excel' is not defined
>>> print(data_pd)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'data_pd' is not defined
但是从中得出什么结论-我不知道
解决方案
推荐阅读
- laravel - 在 Laravel 中找到自定义函数的正确位置在哪里?
- vba - 搜索查找匹配项并将行范围复制到另一个工作表
- cypress - 无法禁用 cypress 屏幕截图
- excel - 如果单元格不为空,则显示“PAID”,如果不显示另一个单元格的值
- javascript - 从两个列表创建一个 json 以在 Javascript 中制作堆叠条形图
- java - 如何在列表视图顶部添加项目并将其保存在数据库中
- java - 两个 Arraylist 具有相同的元素但顺序不同,它们是否相等?
- laravel - 如何保护路线 laravel-5.8
- c - 如果 c 中的结构未按预期方式工作,则嵌套
- python-3.x - 如何识别可被 5 整除到 40 的所有奇数,并保存在列表中