There is no problem with automatic operation in pycharm, ImportError: No module named appears when running on the command line

The program can run in the development environment, but the command line will not work. The project directory is shown in the figure:

codes_no_useful_local is the project directory, A and B are two folders, there is a script in the A directory, and a script in the B directory. The code in is to call the function in, but it needs to be added The above and below codes can be executed through the command line, otherwise, the imported package cannot be found.

import  sys
import os

project = 'codes_no_useful_local'
from B import func



Guess you like