Pycharm DLL issues with run vs debug

1,186 views
Skip to first unread message

Benjam901

unread,
Mar 6, 2015, 10:56:10 AM3/6/15
to python_in...@googlegroups.com
Hello all,

I am having a bit of trouble with the Pycharm debugger and I cannot wrap my head around it.

My application uses PyQt4 and when I import and run the program regularly all is well and the dialog pops up and things populate etc.

But when I run it in debug mode I get the following error:

Traceback (most recent call last):
  File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 139.1485\helpers\pydev\pydevd.py", line 2217, in <module>
    globals = debugger.run(setup['file'], None, None)
  File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 139.1485\helpers\pydev\pydevd.py", line 1643, in run
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "D:/projects/Tools/UnitManager/scripts/__main__.py", line 13, in <module>
    from PyQt4 import QtGui
ImportError: DLL load failed: The specified procedure could not be found.

I am quite confused since everything runs as expected when I run the application normally.

Has anyone encountered this issue with PyCharm debugger or perhaps another application.

PyCharm uses pydev to do its debugging by the looks of it

Cheers,

Ben

Justin Israel

unread,
Mar 6, 2015, 4:24:29 PM3/6/15
to python_in...@googlegroups.com
I don't have any experience with PyCharm, or using a debugger with PyQt apps in Windows... but as a guess, maybe debug mode is trying to load debug symbols or perform extended import operations that non-debug mode doesn't do. And that maybe it isn't using a properly configured environment to find the PATH to the dlls? Can you check whatever env configuration PyCharm provides for its debug mode and ensure you are adding in the location of the PyQt DLLs?

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/c8064e40-47d7-4213-a39e-0f4e010f610d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Marcus Ottosson

unread,
Mar 7, 2015, 2:32:40 PM3/7/15
to python_in...@googlegroups.com

I don’t have experience with PyCharm either, but you’ll get errors like these if required binaries can’t be found.

If you got the official Riverbank distribution, then it’ll add the PyQt4 directory to your PATH. It’s possible that PyCharm modifies this which would cause an error like this.

You could very this if you add this before using the PyQt libraries (e.g. before instantiating QApplication).

import os
import PyQt4

os.environ["PATH"] += ";" + os.path.dirname(PyQt4.__file__)

That’ll expose the binaries again, at which point you should be able to use PyQt4 regardless of alterations to your PATH.

Another possibility is if PyCharm chooses to use another executable for Python.

PyQt needs a qt.conf file next to wherever the executable is, so if it’s different its likely it won’t be there.

You can verify this by printing this in debugging mode.

import os
import sys

dirname = os.path.dirname(sys.executable)
qtconf = os.path.join(dirname, "qt.conf")
print "qt.conf OK" if os.path.isfile(qtconf) else "qt.conf MISSING"

LIJU kunnummal

unread,
Mar 8, 2015, 3:53:37 PM3/8/15
to python_in...@googlegroups.com
Hi Benjamin,
You better cross check your project settings whether PyQt4 is listed in the package section or not. Actually it should automatically add all the packages from the interpreter you have selected.
if not please re-configure the interpreter for your project.

Thanks
Liju K

Ben Hearn

unread,
Mar 8, 2015, 4:25:01 PM3/8/15
to python_in...@googlegroups.com
Hello Liju,

I have checked the project interpreter and PyQt4 is not on the packages listing, I have tried to install but I keep getting the error:

Collecting PyQt4
  Could not find any downloads that satisfy the requirement PyQt4
  No distributions at all found for PyQt4

I have pip installed and all the other packages seem to install correctly. Is there a manual way to do this i.e. copy over PyQt4 from the python27 directory to somewhere else?

Cheers,

Ben

--
You received this message because you are subscribed to a topic in the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python_inside_maya/uVfecbv9XEM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/8cb1a2f7-9a29-4aa6-88dd-826e7e884ad1%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

Tel - +46 76245 92 90 (Sweden)

Justin Israel

unread,
Mar 8, 2015, 5:17:04 PM3/8/15
to python_in...@googlegroups.com

Does PyCharm try and download packages automatically from Pypi? It's not going to work with PyQt if it tries. I assumed the fix only involves updating the project settings to find PyQt on the PYTHONPATH. If it is anything like the pydev from Eclipse, that should be all it cares about. Copying libs around would just be a hack instead of adjusting paths in the env.


You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAM2ybkXdj-7CS5rf%2BE%3D41uYJZzo550j0ysiMWwsShavZCsXfzA%40mail.gmail.com.

Ben Hearn

unread,
Mar 9, 2015, 10:21:00 AM3/9/15
to python_in...@googlegroups.com
Yes Pycharm tries to download automatically from pypi. It it uses PyDev from eclipse to debug. I have appended the PYTHONPATH using sys.path.append and have added the qtconf file as per Marcus' answer and also:

sys.path.append('C:\\Python27\\lib\\site-packages\\pyqt4')


But I have had no luck as of yet. If I remove from PyQt4 import QtGui then the process continues through which makes me think I could be missing a QtGui DLL file from somewhere? But the issue is if I was indeed missing a QtGui file the application would not allow me to run normally which really has be stumped. 

If I have to use another application to debug I will but I would honestly rather not as it could get messy and annoying having to jump from one to the other


For more options, visit https://groups.google.com/d/optout.

Marcus Ottosson

unread,
Mar 9, 2015, 11:48:30 AM3/9/15
to python_in...@googlegroups.com

I have appended the PYTHONPATH using sys.path.append and have added the qtconf file as per Marcus’ answer

Could you take me through what you did exactly?

and also: sys.path.append(‘C:\Python27\lib\site-packages\pyqt4’)

I think you may have misunderstood me here, this is not the same as:

os.environ["PATH"] += ";" + "C:\\Python27\\lib\\site-packages\\pyqt4"

Adding to sys.path is the equivalent of adding to your PYTHONPATH and has nothing to do with the PyQt binaries, which will look at your PATH.

What did you do with the qt.conf file? The contents of this file is also very important and relative to where you put it.

Ben Hearn

unread,
Mar 9, 2015, 12:12:17 PM3/9/15
to python_in...@googlegroups.com
Hello Marcus,

I have removed my sys.path.append line and have left it as you have suggested.
import sys
import os
import PyQt4

dirname = os.path.dirname(sys.executable)
qtconf = os.path.join(dirname, "qt.conf")
os.environ["PATH"] += ";" + os.path.dirname(PyQt4.__file__)

print os.environ["PATH"]
print "qt.conf OK", qtconf if os.path.isfile(qtconf) else "qt.conf MISSING"

from PyQt4 import QtGui

I did not change or alter the qt.conf file or change it's location. Should I have dug out the conf file and made an alternate copy somewhere? The check prints out that the qt.conf file is ok but I am still getting the error:

ImportError: DLL load failed: The specified procedure could not be found.


--
You received this message because you are subscribed to a topic in the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python_inside_maya/uVfecbv9XEM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python_inside_m...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Marcus Ottosson

unread,
Mar 9, 2015, 12:33:05 PM3/9/15
to python_in...@googlegroups.com

Have a look within the qt.conf file, it’s a simple ConfigFile format (i.e. a .ini file).

It should point to where the Qt binaries are; typically in your PyQt4 directory. If the paths are relative, and you move the file, then the resulting absolute paths will be bad. You can safely put in the absolute path to the binaries, just make sure to use forward slashes (/) and not backslashes (\).

​For example:

[Paths]
Prefix = C:/Python27/Lib/site-packages/PyQt4
Binaries = C:/Python27/Lib/site-packages/PyQt4

Did you find out whether it were using a different executable? If it’s using the same as before, then this is likely not the problem.

You can print the executable using sys.executable. It should tell you which one is currently being used.

Ben Hearn

unread,
Mar 9, 2015, 12:42:28 PM3/9/15
to python_in...@googlegroups.com
No PyCharm is using the same C:\Python27\python.exe executable for both run and debug mode. I had a look at the conf file and it is the same as your conf file above. Should I have changed the location of the conf file to my project directory?

--
You received this message because you are subscribed to a topic in the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python_inside_maya/uVfecbv9XEM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python_inside_m...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Marcus Ottosson

unread,
Mar 9, 2015, 1:15:36 PM3/9/15
to python_in...@googlegroups.com
In that case my advice is no good, sorry. I can't say for sure what's going on without know more about what PyCharm does in debug mode.​

Ben Hearn

unread,
Mar 9, 2015, 1:16:40 PM3/9/15
to python_in...@googlegroups.com
No problem at all Marcus, thanks for the help thus far. If I manage to figure out what is going on I shall post up my answers :)

On 9 March 2015 at 18:15, Marcus Ottosson <konstr...@gmail.com> wrote:
In that case my advice is no good, sorry. I can't say for sure what's going on without know more about what PyCharm does in debug mode.​

--
You received this message because you are subscribed to a topic in the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python_inside_maya/uVfecbv9XEM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python_inside_m...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Ben Hearn

unread,
Mar 10, 2015, 5:37:33 AM3/10/15
to python_in...@googlegroups.com
Hello all,

so....after a complete uninstall of all other Python versions and PyCharm itself and then a clean reinstall of Python 27, PyQt4 and all other modules required, the debug mode works ok. Thank you for the help I will be using the advice given in this thread in the future!

If anyone else ever has an issue like this try a clean reinstall

Cheers,

Ben

fengyu...@gmail.com

unread,
Jul 13, 2017, 3:42:25 PM7/13/17
to Python Programming for Autodesk Maya
Hi All,

I had this issue and figured it out it can be resolved easily, don't need to re-install everything. So put solution here in case anyone has similar issue.

Open setting window and select Python Debugger, then uncheck option "PyQt compatible".

Thanks,
Tom

Benjam901

unread,
Jul 14, 2017, 4:58:15 AM7/14/17
to Python Programming for Autodesk Maya
Hello Tom,

I tried your approach and unfortunately it was no dice for me. The only way I have been able to get this to work is by using a solution posted above. Did you change any other settings in PyCharm?

from Qt import QtCore, QtGui, QtWidgets
if False:
   from PyQt4 import QtGui, QtCore
   QtWidgets = QtGui

- Ben

Fengyu Yan

unread,
Jul 14, 2017, 12:07:01 PM7/14/17
to python_in...@googlegroups.com
Hi Ben,

Sorry it doesn't work for you. I only changed this option, then it's working. BTW, I am using the latest Pycharm version 2017.1.5, not sure if it's related to version.

Thanks,
Tom

--
You received this message because you are subscribed to a topic in the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python_inside_maya/uVfecbv9XEM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/12c95a8e-8232-4515-a52f-f39e12e873ca%40googlegroups.com.

Ben Hearn

unread,
Jul 14, 2017, 2:53:19 PM7/14/17
to python_in...@googlegroups.com
I see. I will update to the latest version and will post my results.

- Ben

On 14 Jul 2017 18:07, "Fengyu Yan" <fengyu...@gmail.com> wrote:
Hi Ben,

Sorry it doesn't work for you. I only changed this option, then it's working. BTW, I am using the latest Pycharm version 2017.1.5, not sure if it's related to version.

Thanks,
Tom
On Fri, Jul 14, 2017 at 1:58 AM, Benjam901 <benandr...@gmail.com> wrote:
Hello Tom,

I tried your approach and unfortunately it was no dice for me. The only way I have been able to get this to work is by using a solution posted above. Did you change any other settings in PyCharm?

from Qt import QtCore, QtGui, QtWidgets
if False:
   from PyQt4 import QtGui, QtCore
   QtWidgets = QtGui

- Ben



On Thursday, 13 July 2017 21:42:25 UTC+2, Fengyu Yan wrote:
Hi All,

I had this issue and figured it out it can be resolved easily, don't need to re-install everything. So put solution here in case anyone has similar issue.

Open setting window and select Python Debugger, then uncheck option "PyQt compatible".

Thanks,
Tom

--
You received this message because you are subscribed to a topic in the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python_inside_maya/uVfecbv9XEM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python_inside_maya+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python_inside_maya/uVfecbv9XEM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python_inside_maya+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages