我现在使用这个库已经4个月了,但是今天当我尝试导入automagica模块时,它不能正常工作

2024-04-25 15:29:46 发布

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

我正在尝试创建一个excel文件,并使用automagica自动填充数据,但它不起作用。请帮我解决这个问题

这是我的代码:

from automagica import *

excel = Excel()


# Write to cell A1, this is column 1, row 1
excel.write_cell(1, 1, "Name")

# Write to cell, B1, this is column 2, row 1
excel.write_cell(2, 1, "Address")

# Write to cell, B1, this is column 3, row 1
excel.write_cell(3, 1, "Company")

# Write to cell A2, this is column 1, row 2
excel.write_cell(1, 2, generate_random_name())

# Write to cell A3, this is column 1, row 3
excel.write_cell(1, 3, generate_random_name())

# Write to cell A4, this is column 1, row 4
excel.write_cell(1, 4, generate_random_name())

# Write to cell A5, this is column 1, row 5
excel.write_cell(1, 5, generate_random_name())

# Write to cell A6, this is column 1, row 6
excel.write_cell(1, 6, generate_random_name())

# Write to cells B2, B3, B4, B5 and B6. This is row 2, cells 2 to 6
for i in range(2,7):
    excel.write_cell(2,i,generate_random_address())

# Write to cell range C2:C6. This is row 3, cells 2 to 6
excel.write_range('C2:C6', "Example Company")

# Declare path to save it to, in this case in the homedir with the name "awesome_excel.xlsx"
excel_save_path = home_path(r'D:\suneel\WFH work\Automagica\awesome_excel.xlsx')

# Save the worksheet, by default this is in the homedir
excel.save_as(excel_save_path)

excel.quit()

open_file(excel_save_path)

错误:

I am getting an error when I tried to run automagica code

I installed automagica library but I couldn't able to import

提前谢谢


Tags: topathnameinissavecellcolumn
1条回答
网友
1楼 · 发布于 2024-04-25 15:29:46

似乎内部的PIP存储库包被Netcall公司删除了,可能是他们让这个产品成为非免费的,并删除了它的源代码

只剩下空的pip包,这就是为什么模块仍然可以安装pip,但内部不包含任何源代码。据this history报道,10月16日,该包裹被拆除

但是这个PIP模块仍然有github项目,here。其来源也于10月13日被删除。但git历史记录并没有被删除,我将展示下一步如何从git以前的历史记录中安装pip模块

在命令行内(临时或可写目录中的某个位置)执行以下步骤:

git clone https://github.com/automagica/automagica/
cd automagica
git checkout master
git reset  hard ae8a184

这将最迟在源代码删除之前(ae8a184)提交git存储库

现在执行下一个命令(在签出的git存储库(文件夹automagica)中):

python -m pip install -e .

这将从github存储库安装pip模块。完成了

注意。您可能还想将这个签出的git存储库(文件夹automagica)保存在您的归档文件中的某个地方,我相信,如果他们真的想关闭项目的源代码,公司很快也会删除这个git存储库

如果上面的最后一个安装命令由于某种原因失败,请在签出的git存储库(文件夹automagica)中执行以下步骤:

python setup.py bdist_wheel

此命令将生成/复制项目源到PIP wheel包。如果命令成功,转到./dist/子文件夹,将有扩展名为.whl的文件,如我的电脑上的Automagica-3.2.2-py3-none-any.whl。只需通过下一个pip命令安装即可:

python -m pip install Automagica-3.2.2-py3-none-any.whl

最后一个命令在我的Windows PC上运行,之后import automagica在Python代码中运行

相关问题 更多 >