PyCharm should detect relative paths in Analyze Stacktrace


Hey all! I am on PyCharm Pro 2018.1.3.

I have noticed a behavioral oddity while attempting to use the Analyze Stack functionality with an external stack trace: PyCharm does not play well with relative paths. Easier to explain with an example:

Exhibit A works

File "/users/myuser/myproj/", line 50, in main

Exhibit B does not work

File "myproj/", line 50, in main

Am I misconfigured somewhere? How can I work around this? Is this something that might be remedied in a future version?



Hi bestsharper! Could you please provide a code snippet to generate such stacktrace?


Sure, easy enough.


Consider this basic code snippet:

def foo():
raise Exception()


Save it as in your home directory (e.g. /Users/myuser/

Execute it: python /Users/myuser/

You will receive the following stack:

Traceback (most recent call last):
File "/Users/myuser/", line 4, in <module>
File "/Users/myuser/", line 2, in foo
raise Exception()

You can now plug that into PyCharm with Analyze Stacktrace and have the code navigable to the exact line.

However, try mangling the path to the file making it different from where it is located on local (or at the time the stack was obtained):

- pretend you have deployed the code on a live env and replace /Users/myuser with a different path

- execute the code without a full path, aka python which will omit the full path from the stack

- move the file to a new location before opening it

For example,

Traceback (most recent call last):
File "/my/deployed/environment/", line 4, in <module>
File "/my/deployed/environment/", line 2, in foo
raise Exception()

Plugging that stack in causes PyCharm to not perform any analysis.


The application here is analyzing stack traces not produced by local machine (e.g. other devs or prod/qa/other envs):




The issue here is that prod stacks will never match whatever the paths local dev might have. One work-around is to find-replace the part of the path that does not match, but it seems like an IDE ought to be able to do something with the info it has.


I'm experiencing the same frustration while using PyCharm on the host machine and running tests in a VM.


Reproduced the issue by changing script path in the run configuration from absolute to relative.

@Pavel Karateev

Do you have any input?


Please vote for the corresponding feature requests:

  • PY-25526 Analyze stacktrace does not recognize path mapping from remote interpreter
  • PY-10501 Stack analysis fails if path prefix doesn't match

Please sign in to leave a comment.