Can run simple app with custom import in PyCharm but debugger can't resolve import

I have a simple Python script that imports a custom module in the same directory.  The script runs fine in PyCharm CE 2019.1.2 but if I try to run it in the debugger, it doesn't import the custom module.


$ cat
#! /usr/bin/env python

import logging
import argparse

import common

parser = argparse.ArgumentParser(description='import_test')
parser.add_argument('-v', '--verbose', dest='verbose', action='store_true', help='Enable debugging')
args = parser.parse_args()

logging.basicConfig(format='%(asctime)s %(levelname)s %(pathname)s:%(lineno)d %(msg)s')
log = logging.getLogger()
log.setLevel(logging.DEBUG if args.verbose else logging.INFO)

obj = common.Obj()'obj.value: {obj.value}'.format(**locals()))

$ cat
class Obj(object):
def __init__(self):
self.value = 42

$ ./
2019-06-14 09:31:21,781 INFO ./ obj.value: 42


The script behaves the same way when I run it inside PyCharm but the debugger fails:

C:\cygwin64\bin\python2.7.exe "C:\Program Files\JetBrains\PyCharm Community Edition 2019.1.1\helpers\pydev\" --multiproc --qt-support=auto --client --port 58659 --file C:/cygwin64/home/jpfuntne/fun/import_test/
pydev debugger: process 1335 is connecting

Connected to pydev debugger (build 191.7141.48)
pydev debugger: warning: trying to add breakpoint to file that does not exist: /home/jpfuntne/fun/import_test/c:/cygwin64/home/jpfuntne/fun/import_test/ (will have no effect)
Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.1.1\helpers\pydev\", line 1758, in <module>
File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.1.1\helpers\pydev\", line 1752, in main
globals =['file'], None, None, is_module)
File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.1.1\helpers\pydev\", line 1147, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "C:/cygwin64/home/jpfuntne/fun/import_test/", line 6, in <module>
import common
ImportError: No module named common


I created with the example scripts.

I was able to start the debugger when I used C:\Users\jpfuntne\AppData\Local\Programs\Python\Python37\python.exe or C:\cygwin64\home\jpfuntne\repos\ultra-utils\venv\Scripts\python.exe as the interpreter.

The problem occurs when I use C:\cygwin64\bin\python2.7.exe as the interpreter.


I want to use Python 2.7 so I didn't want to use C:\Users\jpfuntne\AppData\Local\Programs\Python\Python37\python.exe.

C:\cygwin64\home\jpfuntne\repos\ultra-utils\venv\Scripts\python.exe is 2.7.15 but for some reason the socket module was different than expected.  It's missing some method such as socket.socket.inet_pton().

C:\cygwin64\bin\python2.7.exe is 2.7.16 and it has socket.socket.inet_pton() but the PyCharm debugger won't start my script properly.



Where did you install C:\cygwin64\bin\python2.7.exe from? I could try to reproduce it on my side.
Is there a chance that there is a conflict in module names? Maybe there is another custom module or some module installed from PyPI?


Please sign in to leave a comment.