I am running a Python client using PyCharm. If I just run it, PyCharm simply calls:
C:\Python27\python.exe E:/faf/client/src
and everything is fine.
These are my settings:
If I want to debug it, PyCharm calls:
C:\Python27\python.exe "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 5.0.2\helpers\pydev\pydevd.py" --multiproc --qt-support --client 127.0.0.1 --port 52948 --file E:/faf/client/src
and the result is that the modules which are in fact there cannot be included
pydev debugger: process 5092 is connecting
Connected to pydev debugger (build 143.1184)
Traceback (most recent call last):
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 5.0.2\helpers\pydev\pydevd.py", line 2407, in <module>
globals = debugger.run(setup['file'], None, None, is_module)
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 5.0.2\helpers\pydev\pydevd.py", line 1798, in run
launch(file, globals, locals) # execute the script
File "E:/faf/client/src\__main__.py", line 29, in <module>
import config
ImportError: No module named config
What do I have to do to be able to debug this thing?
I had to click on the src directory and add it as source folder (Mark Directory As -> Source Root). No apparent thing changed like e.g. the way the python command got called.
So if you have a similar looking problem try to do the same.
I resolved this issue for myself by adding an init.py in the folder of the module I was trying to import.
Related
I dont know why; but since python 3.8 has been released; I cant run pycharm console and it is always in the "being connected" status.
I have had no problem with python 3.7; since the console is opened immediately.
Here you can see that I have tried several times to run the console but I know, even if I wait a day; It does not connect to console; but when I change the interpreter from python3.8 to python3.7, The new consoles I open are all set up within a second.
The Error:
C:\Program Files\JetBrains\PyCharm 2019.1.3\helpers\pydev\_pydevd_bundle\pydevd_resolver.py:138: SyntaxWarning: "is not" with a literal. Did you mean "!="?
if found.get(name) is not 1:
Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm 2019.1.3\helpers\pydev\pydevconsole.py", line 33, in <module>
from _pydev_bundle.pydev_console_utils import BaseInterpreterInterface
File "C:\Program Files\JetBrains\PyCharm 2019.1.3\helpers\pydev\_pydev_bundle\pydev_console_utils.py", line 11, in <module>
from _pydevd_bundle import pydevd_thrift
File "C:\Program Files\JetBrains\PyCharm 2019.1.3\helpers\pydev\_pydevd_bundle\pydevd_thrift.py", line 17, in <module>
from pydev_console.protocol import DebugValue, GetArrayResponse, ArrayData, ArrayHeaders, ColHeader, RowHeader, \
File "C:\Program Files\JetBrains\PyCharm 2019.1.3\helpers\pydev\pydev_console\protocol.py", line 6, in <module>
_console_thrift = _shaded_thriftpy.load(os.path.join(os.path.dirname(os.path.realpath(__file__)), "console.thrift"),
File "C:\Program Files\JetBrains\PyCharm 2019.1.3\helpers\third_party\thriftpy\_shaded_thriftpy\parser\__init__.py", line 29, in load
thrift = parse(path, module_name, include_dirs=include_dirs,
File "C:\Program Files\JetBrains\PyCharm 2019.1.3\helpers\third_party\thriftpy\_shaded_thriftpy\parser\parser.py", line 502, in parse
parser.parse(data)
File "C:\Program Files\JetBrains\PyCharm 2019.1.3\helpers\third_party\thriftpy\_shaded_ply\yacc.py", line 331, in parse
return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc)
File "C:\Program Files\JetBrains\PyCharm 2019.1.3\helpers\third_party\thriftpy\_shaded_ply\yacc.py", line 1106, in parseopt_notrack
p.callable(pslice)
File "C:\Program Files\JetBrains\PyCharm 2019.1.3\helpers\third_party\thriftpy\_shaded_thriftpy\parser\parser.py", line 212, in p_struct
val = _fill_in_struct(p[1], p[3])
File "C:\Program Files\JetBrains\PyCharm 2019.1.3\helpers\third_party\thriftpy\_shaded_thriftpy\parser\parser.py", line 765, in _fill_in_struct
gen_init(cls, thrift_spec, default_spec)
File "C:\Program Files\JetBrains\PyCharm 2019.1.3\helpers\third_party\thriftpy\_shaded_thriftpy\thrift.py", line 103, in gen_init
cls.__init__ = init_func_generator(default_spec)
File "C:\Program Files\JetBrains\PyCharm 2019.1.3\helpers\third_party\thriftpy\_shaded_thriftpy\_compat.py", line 102, in init_func_generator
new_code = types.CodeType(len(varnames),
TypeError: an integer is required (got type bytes)
The Photo:
(source: techpowerup.org)
pycharm specs: pycharm professional version 2019.1.3
It works fine on PyCharm (Community) 2019.3.
PyCharm ships [PyPI]: thriftpy (for current version, it's a modified v0.3.8), as it needs it for different features (including the Python Console).
Python 3.8 came with a set of changes (one example is [Python]: PEP 570 -- Python Positional-Only Parameters) requiring changes in many of the existing (3rd-party) packages in order for them to work (for some of them, there's still WiP).
Apparently, ThriftPy is one of those packages that require changes. However it hasn't been maintained since 2016, so JetBrains keeps (a copy / fork ?) in their repository.
Anyway, the problem you're facing, was fixed by [GitHub]: JetBrains/intellij-community - PY-36069 Python console support for Python 3.8. Unfortunately, I couldn't find the issue on JetBrains.YouTrack, so I don't have any additional info about it (like when it was fixed, and so on).
What I can tell you (also mentioned at the beginning), is that it was fixed (works) in PyCharm (Community) 2019.3, so if you upgrade it, you should no longer have this problem.
A workaround (if upgrading is not an option) would be to apply the patch (in the commit URL) to your (local) _compat.py file. Check [SO]: Run / Debug a Django application's UnitTests from the mouse right click context menu in PyCharm Community Edition? (#CristiFati's answer) (Patching utrunner section) for how to apply patches (on Win).
Small mention: applying the reversed patch to my local file, made the problem visible.
Delete your code program and reload it from git or other svn, it would be ok for Pycharm 2021.2.3 Professional Edition.
This question is similar to this one. I am trying to debug pyethapp
with the following configuration:
The entry point is located in app.py. The code runs fine when not being debugged, but once I launch the debugger the following exception is thrown:
Failed to import scrypt. This is not a fatal error but does
mean that you cannot create or decrypt privkey jsons that use
scrypt
/usr/local/lib/python2.7/dist-packages/cffi/model.py:526: UserWarning: 'point_conversion_form_t' has no values explicitly defined; next version will refuse to guess which integer type it is meant to be (unsigned/signed, int/long)
% self._get_c_name())
Traceback (most recent call last):
File "/home/user/Utils/pycharm-community-2016.1/helpers/pydev/pydevd.py", line 1530, in <module>
globals = debugger.run(setup['file'], None, None, is_module)
File "/home/user/Utils/pycharm-community-2016.1/helpers/pydev/pydevd.py", line 937, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "app.py", line 27, in <module>
from console_service import Console
File "/home/user/Utils/pycharm-community-2016.1/helpers/pydev/_pydev_bundle/pydev_monkey_qt.py", line 71, in patched_import
return original_import(name, *args, **kwargs)
File "console_service.py", line 38, in <module>
#inputhook_manager.register('gevent')
AttributeError: 'InputHookManager' object has no attribute 'register'
The solution suggested here (reinstalling ipython) did not solve the issue (it occurs only when debugging; the client works when run separately).
Edit:
Command line in output:
/usr/bin/python2.7 /home/user/Utils/pycharm-community-2016.1/helpers/pydev/pydevd.py --cmd-line --multiproc --qt-support --client 127.0.0.1 --port 59087 --file app.py --profile testnet --data-dir testnetState/ run
warning: Debugger speedups using cython not found. Run '"/usr/bin/python2.7" "/home/user/Utils/pycharm-community-2016.1/helpers/pydev/setup_cython.py" build_ext --inplace' to build.
pydev debugger: process 20493 is connecting
Connected to pydev debugger (build 145.260)
Failed to import scrypt. This is not a fatal error but does
mean that you cannot create or decrypt privkey jsons that use
scrypt
/usr/local/lib/python2.7/dist-packages/cffi/model.py:526: UserWarning: 'point_conversion_form_t' has no values explicitly defined; next version will refuse to guess which integer type it is meant to be (unsigned/signed, int/long)
% self._get_c_name())
Traceback (most recent call last):
File "/home/user/Utils/pycharm-community-2016.1/helpers/pydev/pydevd.py", line 1530, in <module>
globals = debugger.run(setup['file'], None, None, is_module)
File "/home/user/Utils/pycharm-community-2016.1/helpers/pydev/pydevd.py", line 937, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "app.py", line 27, in <module>
from console_service import Console
File "/home/user/Utils/pycharm-community-2016.1/helpers/pydev/_pydev_bundle/pydev_monkey_qt.py", line 71, in patched_import
return original_import(name, *args, **kwargs)
File "console_service.py", line 38, in <module>
#inputhook_manager.register('gevent')
AttributeError: 'InputHookManager' object has no attribute 'register'
This error is known to happen if you use old versions of IPython (in which indeed the method register was not yet implemented). As you presumably use OSX, in which a default Python install is included, there might be some conflicting Ipython copies in your environment, different versions of which are called by the regular and debugging configurations?
This problem is probably resolved by moving the project to a virtual environment in which your root packages cannot interfere.
To get rid of cython missing warning, run:
python2 /.......git/liclipse/plugins/org.python.pydev_6.2.0.201711281546/pysrc/setu p_cython.py build_ext --inplace
Finally the debug window stay clean of those dreaded warnings and cluttering.
I cannot debug a Flask application in PyCharm. The application should run on port 5000: app.run(host="10.1.0.17", port=5000, debug=True). The console output is:
C:\Python\python.exe "C:\Program Files (x86)\JetBrains\PyCharm 145.597.11\helpers\pydev\pydevd.py" --multiproc --qt-support --client 127.0.0.1 --port 10498 --file "D:/TGM/SMS/SMS/Back .v2/wsgi.py"
pydev debugger: process 4108 is connecting
Could not connect to 127.0.0.1: 10499
Traceback (most recent call last):
File "C:\Program Files (x86)\JetBrains\PyCharm 145.597.11\helpers\pydev\pydevd.py", line 1523, in <module>
debugger.connect(host, port)
File "C:\Program Files (x86)\JetBrains\PyCharm 145.597.11\helpers\pydev\pydevd.py", line 317, in connect
self.initialize_network(s)
File "C:\Program Files (x86)\JetBrains\PyCharm 145.597.11\helpers\pydev\pydevd.py", line 304, in initialize_network
self.writer = WriterThread(sock)
File "C:\Program Files (x86)\JetBrains\PyCharm 145.597.11\helpers\pydev\_pydevd_bundle\pydevd_comm.py", line 392, in __init__
self.cmdQueue = _queue.Queue()
AttributeError: module 'queue' has no attribute 'Queue'
Process finished with exit code -1
I am using Python 3.5.1. What could be wrong?
The pydev debugger uses the same Pythonpath as the project you are trying to debug.
If you have any modules or packages with names of standard modules or packages, the pydev debugger might load your module instead of the standard module.
You probably have a module called queue in your projects directories, which causes this issue, since the python standard library also includes a module with that name.
try renaming your module, or changing your PYTHONPATH
PyCharm has the option to not include the projects root/source roots in the PYTHONPATH in Run > Edit Configurations. This could fix your problem, although you might need to fix some import statements in your project, if any of your import statements relied on this setting.
I just downloaded PyCharm community edition and every time I try to debug any Python program in PyCharm, I get this error:
C:\Python31\python.exe "C:\Program Files (x86)\JetBrains\PyCharm Community
Edition 2016.1\helpers\pydev\pydevd.py" --multiproc --qt-support --client 127.0.0.1 --port 59207 --file C:/Users/Gal/PycharmProjects/untitled/test.py
pydev debugger: process 5388 is connecting
Connected to pydev debugger (build 145.260)
Traceback (most recent call last):
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.1\helpers\pydev\pydevd.py", line 1530, in <module>
globals = debugger.run(setup['file'], None, None, is_module)
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.1\helpers\pydev\pydevd.py", line 937, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.1\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 11, in execfile
stream = tokenize.open(file) # #UndefinedVariable
AttributeError: 'module' object has no attribute 'open'
and a python file named "_pydec_excecfile.py" opens:
#We must redefine it in Py3k if it's not already there
def execfile(file, glob=None, loc=None):
if glob is None:
import sys
glob = sys._getframe().f_back.f_globals
if loc is None:
loc = glob
# It seems that the best way is using tokenize.open(): http://code.activestate.com/lists/python-dev/131251/
import tokenize
stream = tokenize.open(file) # #UndefinedVariable
try:
contents = stream.read()
finally:
stream.close()
#execute the script (note: it's important to compile first to have the filename set in debug mode)
exec(compile(contents+"\n", file, 'exec'), glob, loc)
How can I fix it?
I had a similar situation in a project that had a file named 'tokenizer.py'.
While trying to debug a different Python code in the same project (even in a different file) I got the following error output:
Traceback (most recent call last):
File "C:\Programs\PyCharm\plugins\python-ce\helpers\pydev\pydevd.py", line 1483, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "C:\Programs\PyCharm\plugins\python-ce\helpers\pydev\_pydev_imps \_pydev_execfile.py", line 11, in execfile
stream = tokenize.open(file) # #UndefinedVariable
AttributeError: module 'tokenize' has no attribute 'open'
I could run the code, but not debug it. Then I found a discussion at link, the idea there was that a module in the code shadowed some top level package required by the debugger. I renamed the 'tokenizer' module, and debugging was possible again.
This seems to be the recipe: try to rename the module mentioned in the error output.
I am having problens debugging my code. When I use OpenCV by importing cv2 I get the following output:
pydev debugger: process 8272 is connecting
Connected to pydev debugger (build 141.1899)
Traceback (most recent call last):
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.5.3\helpers\pydev\pydevd.py", line 2358, in <module>
globals = debugger.run(setup['file'], None, None, is_module)
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.5.3\helpers\pydev\pydevd.py", line 1778, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "C:/work/210 Python/6 imagingSource/test.py", line 3, in <module>
import cv2
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.5.3\helpers\pydev\pydev_monkey_qt.py", line 71, in patched_import
return original_import(name, *args, **kwargs)
ImportError: DLL load failed: Die angegebene Prozedur wurde nicht gefunden.
So some DLL can not be loaded. I do not get the error when I normally run the file.
I checked the run and debug environments with the os package. They are almost the same, differing only in some additional entries for the pydev debug environment. I think I also checked whether or not a 64bit interpreter is being used by executing sys.maxsize in both environments. They return the same values so I guess they are both the same - 64bit.
So I am without a clue what could be the cause of this issue. Does anyone have an idea?
Thanks in advance!