I am trying to debug the code in corporate server, however, I need to get permission by using a sepcific command(make it short, I'll call it p
). How could I debug in pycharm with a start command
p python main.py
I tried to edit configuration, but neither parameters nor interpreter options worked as I expected. Are there any settings can modify the command to start python?
The ability of showing value of variable using pdb
just not satisfy my requirements.
CodePudding user response:
This worked for me on macOS 11. Since I don't know what p
in your question is, I used the time
command for testing:
Created a shell script named /var/tmp/python
and made it an executable (chmod x /var/tmp/python
):
#!/bin/sh
time /usr/bin/python3 "$@"
The "$@"
is used to pass all command line arguments passed to /var/tmp/python
to the actual /usr/bin/python3
.
Then I added a new System Interpreter in PyCharm and picked /var/tmp/python
as the executable.
When I debug my "Hello world" application this is the output:
/var/tmp/python /Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd.py --multiproc --qt-support=auto --client 127.0.0.1 --port 53332 --file "/var/tmp/hello_world.py"
Connected to pydev debugger (build 212.5457.59)
Hello, world!
real 0m3.091s
user 0m0.292s
sys 0m0.078s
Process finished with exit code 0
as you can see in addition to executing/debugging the application it also printed the total time passed.