For some reason, there was a bug (ʻImportError: cannot import name'convert') that broke as follows at the import stage, so I will explain how to deal with it. This article talks about a package called
docx2pdf`, but other packages have similar bugs, so I hope it helps those people as well.
python
Traceback (most recent call last):
File "docx2pdf.py", line 5, in <module>
from docx2pdf import convert
File "/Users/xxx.py", line 5, in <module>
from docx2pdf import convert
ImportError: cannot import name 'convert'
The bottom line is that I was trying to import a package called dox2pdf, but I renamed the Python script to docx2pdf.py
. A bug similar to the fact that reserved words cannot be used as variables is that the package name used cannot be used as a file name.
Therefore, when I changed the file name from docx2pdf.py
to main.py
, I was able to execute it safely.
Recommended Posts