在Python 3中遇到了导入错误的问题。 我的项目结构如下:
cts_sap_polaris/
|-- etc
| |-- clean_cts_sap_polaris.yaml
| |-- clean_env_variables.tcl
| |-- cts_sap_polaris_ha_combined.yaml
| |-- cts_sap_polaris.yaml
| `-- TCL_TESTBED_CONFIGS
|-- __init__.py
|-- jobs
| |-- __init__.py
| |-- __pycache__
| | `-- run_cts_sap_polaris.cpython-34.pyc
| `-- run_cts_sap_polaris.py
|-- lib
| |-- cli_check.py
| |-- cts_sap_polaris_utils.py
| |-- __init__.py
| |-- router_show_cts_cmd.py
| |-- router_show_etherchannel_cmd.py
| |-- router_show.py
| |-- utils.py
| |-- validate_show_output.py
| `-- wait_for.py
|-- scripts
| |-- cts_sap_polaris_ha_combined.py
| |-- cts_sap_polaris.py
| |-- __init__.py
| `-- __pycache__
| `-- cts_sap_polaris.cpython-34.pyc
`-- test
|-- code_snippets
|-- cts_interface.json
|-- cts_interface_summary.json
|-- etherchannel_port_channel.json
|-- etherchannel_port.json
|-- __init__.py
|-- test_cts_sap_cli.py
`-- test_router_show.py
我正在尝试在 scripts/cts_sap_polaris.py
中导入
import cts_sap_polaris.lib.cli_check as cli_check
哪个导致了这个错误:
ImportError: No module named 'cts_sap_polaris.lib'; 'cts_sap_polaris' is not a package.