简体   繁体   中英

Pycharm - Import Module in Python - Different behaviour - MAC vs Windows

My folder structure:

  • /backend/webservices.py
  • /backend/csv_utilities.py

webservices.py starts like this:

from flask import Flask, request
from werkzeug.utils import secure_filename
from backend.csv_utilities import *
import os
  • If I run webservices.py on MAC, I won't have any problems.
  • If I run webservices.py on Windows, I will get a module not found error.

Changing webservices.py like this:

from flask import Flask, request
from werkzeug.utils import secure_filename
from csv_utilities import *
import os

works on both ; MAC and 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'.

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?

I had a similar issue once. Try Mark directory as Sources Root option on your backend folder. It worked for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM