我正在尝试使用PyCharm调试我的测试,但我目前收到此错误:
pydev debugger: process 2386 is connecting
Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 2222, in <module>
globals = debugger.run(setup['file'], None, None)
File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1648, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "/Applications/PyCharm.app/Contents/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/Applications/PyCharm.app/Contents/helpers/pycharm/utrunner.py", line 116, in <module>
modules = [loadSource(a[0])]
File "/Applications/PyCharm.app/Contents/helpers/pycharm/utrunner.py", line 40, in loadSource
module = imp.load_source(moduleName, fileName)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/imp.py", line 171, in load_source
module = methods.load()
File "<frozen importlib._bootstrap>", line 1220, in load
File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1129, in _exec
File "<frozen importlib._bootstrap>", line 1471, in exec_module
File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
File "/Users/bli1/Development/Trinity/qa-trinity/python_lib/qe/tests/test_web_events.py", line 21, in <module>
import qe.util.scratchstore as scratchstore
File "/Applications/PyCharm.app/Contents/helpers/pydev/_pydev_imps/_pydev_pluginbase.py", line 452, in plugin_import
fromlist, level)
File "/Applications/PyCharm.app/Contents/helpers/pydev/_pydev_imps/_pydev_pluginbase.py", line 452, in plugin_import
fromlist, level)
File "/Applications/PyCharm.app/Contents/helpers/pydev/_pydev_imps/_pydev_pluginbase.py", line 452, in plugin_import
fromlist, level)
ImportError: No module named 'qe'
通常在终端中,我在测试之前运行此脚本:
$ source ../setup.sh
setup.sh的内容:
#!/bin/bash
[[ $_ != $0 ]] && this_is_sourced=1 || this_is_sourced=""
this_script_path="${BASH_SOURCE[@]}"
if [[ ${this_is_sourced} ]]; then
pushd $(dirname ${this_script_path}) >/dev/null
this_script_dir=$(pwd)
this_script_pkgs=$(echo qe/[a-z]*[a-z0-9] | sed 's%qe/%%g')
popd >/dev/null
#### set environment vars
export PYTHONPATH="$this_script_dir"
export PYTHONDONTWRITEBYTECODE="1"
/usr/bin/env | grep -Fe "PYTHON" >/dev/tty
export PATH="/trinityqa00/opt/bin:/qa00/opt/bin:/home/sthe/opt/bin:${PATH}"
for pkg in $this_script_pkgs; do
export PATH="${PYTHONPATH}/qe/${pkg}:${PATH}"
done
echo "PATH=${PATH}" >/dev/tty
####
unset this_script_dir
unset this_script_path
unset this_is_sourced
else
echo "usage: source ${this_script_path}"
exit
fi