fixing Module Not found Error when importing openpyxl in .py file?

…衆ロ難τιáo~ 提交于 2021-01-29 17:44:01

问题


I am trying to use openpyxl with python 3.7, but when starting my .py file in my windows shell I got the ModuleNotFoundError.

It is kinda weird as i don't get this error if I write my code in the python interpreter (can create and save .xlsx files)

I tried uninstalling and installing again via pip3 and/or running shell as admin (pip is updated). I don't use many other modules (os, wx, csv and calendar) so it shouldn't interfere. I renamed my .py file so i'm sure there is no name conflict.

import openpyxl
#from openpyxl import Workbook (doesn't work either)

Do you have an idea where this may coming from ?

regards,

Clem


回答1:


I think I found a solution, as I don't get the error anymore.

I added the encoding and language interpreter at the beginning of my .py file

#!/usr/bin/env python
# -*- coding: utf-8 -*-
from openpyxl import Workbook

Hope it helps :)



来源:https://stackoverflow.com/questions/57396896/fixing-module-not-found-error-when-importing-openpyxl-in-py-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!