Docker Debugging - Remote file is mapped to the local path and can't be found.

Answered

 

To PyCharm

 

It appears since updating to PyCharm 2019.3.3 I unable to debug a program running in a Docker container with source code. Now when trying to debug in to an imported module I get the error described below. 

Remote file /opt/project/pres/ is mapped to the local path C:\Users\__my_directory__\src\pres\\usr\local\lib\python3.7\site-packages\decorator.py:decorator-gen-704> and can't be found. You can continue debugging, but without the source.

The external libraries are visible in the UI and in the project interpreter (see pics below). The problem only arises when debugging and trying to step in to the imported module.

Image showing debugging source not found:

Image showing packages installed for project interpreter

Image showing source visible by project explorer:

 

The below files allow a full reproduction of the issue. I get the issue when I debug in to line 30 of network.py

Dockerfile

FROM python:3.7

COPY requirements.txt /
RUN pip install -r /requirements.txt

requirements.txt

networkx==2.4
numpy

pres/network.py

import networkx as nx

if __name__ == '__main__':

DG = nx.DiGraph()

DG.add_node(1)
DG.add_nodes_from([2, 3])

DG.add_edge(1, 2)

labeldict = {
1: 'Main',
2: 'Sub1',
3: 'Sub2',

}

print('edges')
for edge in DG.edges():
print(edge)
print(DG.nodes[edge[0]])

print('nodes')
for node in DG.nodes():
print(node)

nodelist = list(DG)

pos = nx.drawing.spring_layout(DG)

print(pos)

 

I hope this helps identify the issue. 

 

Regards,

J

4 comments
Comment actions Permalink

 

The Docker version I am experiencing the issue with:

0
Comment actions Permalink

 

Here is the PyCharm debug configuration

 

0
Comment actions Permalink

 

Apologies for the red herring. There appeared to be two issues:

a. The above file can't be debugged because of the redirection used by networkx

b. A related issue was that my project wasn't able to debug any file. To resolve this I wiped all my docker images and started again.

0
Comment actions Permalink

Hi,

Thanks for providing all the files for reproducing the issue.

Here is the ticket in our issue tracker https://youtrack.jetbrains.com/issue/PY-40745, feel free to vote and leave comments.

0

Please sign in to leave a comment.