1. For my automated test engineering structure diagram
I started my automated test by running the Run.bat batch file, calling the cmd console to run start_run.py, but the following error occurred:
You may know that our project runs in the IDE (PYCHARM) and we run in CMD in a different way, when running in Pycharm,
The default Pycharm directory + Our project directory is the running directory, and when run in CMD, it will run in the directory where our catalog is located.
In the import package, the package is first viewed from the PYTHONPATH environment variable, and if none of the directories contained in your Pythonpath are
The root directory of the project directory, you will get an import error when you import a package in another project that is not in the same directory
Workaround: Add your project directory to Pythonpath in the file you are running, as follows:
Import Os,sys
Sys.path.append ("path")//path is the absolute path to your project root directory
If you still get an error while running, check to see if the root directory is added to Pythonpath by:
Import OS
PATH = Os.environ
For key in PATH:
Print (Key,path[key])
If the directory contains the project root you are in, then check to see if all of your directories contain __init__ files.
When we import a module under another package, we first need to determine if the package is a Python package, and the __init__ file is
To prove that this directory is a python package directory!
While I was doing something online, I found that I still failed, and I found a __init__ file in my root directory as well.
And I deleted the file, run everything normal, I do not know the specific reason, feel a bit strange!
Resolve Python failed to import package at CMD runtime, error message "Modulenotfounderror:no module named * * * * * *"