折腾:
期间,得知Mac本地shell中,可以通过:pipenv run python testRestApi.py
去是可以正常运行pipenv的虚拟环境中的python3的代码的。
所以此处再去把这个配置到PyCharm中,希望可以实现在PyCharm中正常调试pipenv虚拟环境中的python3的文件。
结果用配置:
去运行出错:
/Users/crifan/.virtualenvs/robotDemo-HXjMJQEQ/bin/python /Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py --multiproc --qt-support=auto --client 127.0.0.1 --port 58605 --file "pipenv run python testRestApi.py"
pydev debugger: process 80603 is connecting
Connected to pydev debugger (build 173.4127.16)
Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1668, in <module>
main()
File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1662, in main
globals = debugger.run(setup['file'], None, None, is_module)
File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1072, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "/Applications/PyCharm.app/Contents/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 11, in execfile
stream = tokenize.open(file) # @UndefinedVariable
File "/Users/crifan/.virtualenvs/robotDemo-HXjMJQEQ/lib/python3.6/tokenize.py", line 452, in open
buffer = _builtin_open(filename, 'rb')
FileNotFoundError: [Errno 2] No such file or directory: 'pipenv run python testRestApi.py'
找了找配置,感觉是自己忘了配置工作目录working directory:
所以去加上working directory为当前pipenv的项目的根目录: