[英]Pycharm - Import Module in Python - Different behaviour - MAC vs Windows
My folder structure: 我的文件夹结构:
webservices.py
starts like this: webservices.py
开始是这样的:
from flask import Flask, request
from werkzeug.utils import secure_filename
from backend.csv_utilities import *
import os
webservices.py
on MAC, I won't have any problems. webservices.py
,则不会有任何问题。 webservices.py
on Windows, I will get a module not found error. webservices.py
,则会收到模块未找到错误。 Changing webservices.py
like this: 像这样更改
webservices.py
:
from flask import Flask, request
from werkzeug.utils import secure_filename
from csv_utilities import *
import os
works on both ; 两者都工作 ; MAC and Windows.
MAC和Windows。 But in PyCharm (on MAC, I didn't try on Windows) now I get an error marked on
csv_utilities
and it says: unresolved reference 'csv_utilities'. 但是在PyCharm中(在MAC上,我没有在Windows上尝试过),现在我得到了一个在
csv_utilities
标记的错误,它说:未解析的引用'csv_utilities'。
Why is this error there? 为什么会出现此错误? I can run it without problems.
我可以毫无问题地运行它。 Is it a Pycharm issue or am I doing something not in the right way?
是Pycharm问题,还是我做事不正确?
I had a similar issue once. 我曾经有过类似的问题。 Try Mark directory as Sources Root option on your backend folder.
尝试在后端文件夹上将目录标记为Sources Root选项。 It worked for me.
它为我工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.