I'm using Sublime-Text3 with SublimeLinter + SublimeLinter-pylint installed.
Everything works as expected, except for pylint "scanning" PyQt4
from PyQt4 import QtCore, QtGui
works OK. Pylint detects QtCore and QtGui, but if
button = QtGui.QPushButton()
layout = QtGui.QVBoxLayout()
pylint sets red underlines and tells that
PyQt4.QtGui has no "QPushButton" member
Is there any way to fix this error or maybe ignore PyQt in SublimeLinter?
recent versions of pylint don't load extensions modules anymore (i.e. compiled code not written in pure python), unless they are listed using the extension-pkg-whitelist option. This is because loading extensions modules requires to actually load the code which may trigger undesired side effects.
In your case, pylint --extension-pkg-whitelist=PyQt4 <your module> (or using equivalent entry in the config file) should fix your problem.
Found the solution, thanks to sthenault
Step by step.
Generate rc file
pylint --generate-rcfile > pylint.rc
Replace the line
extension-pkg-whitelist=
by
extension-pkg-whitelist=PyQt4
Sublime
Preferences -> Package Settings -> SublimeLinter -> Settings - User
"pylint": {
[..another settings..]
"rcfile": "/path_to_rc/pylint.rc",
}
Related
I'm trying to install python application on Windows with pyinstaller where I'm using tkcalendar. Application is working but the tkcalendar.Calendar isn't.
When I'm running application without installation everything works but if I do this, Calendar widget does not appear.
I think that pyinstaller sees this module but he has problems with modules that tkcalendar is using.
I tried to run pyinstaller with --path=/.../python/Lib/site-packages but this didnt worked. Also copying module files to application directory didn't help.
The issue does not come from tkcalendar but from the fact that PyInstaller does not detect second level imports. A way to solve this issue is explained in tkcalendar's documentation in the HowTos section:
When bundling an application with PyInstaller, there is an
issue with the
detection of the babel dependency of tkcalendar. This can be fixed by
using the --hidden-import option:
$ pyinstaller --hidden-import babel.numbers myscript.py
or by editing the .spec file:
hiddenimports=["babel.numbers"]
Add following code to your python script, while bundling with pyinstaller
import babel.numbers
If anyone found the same problem.
In tkcalendar 1.5.0 there is problem with import in calendar.py.
Locate the tkcalendar folder (probably /.../python/Lib/site-packages/tkcalendar) and under calendar.py add an additional import for the missing module:
import calendar
from babel.dates import format_date, parse_date, get_day_names, get_month_names
from babel.numbers import * # Additional Import```
Ok, I am having a weird issue going on. From what I understand Tkinter is supposed to be built in with python 2 and 3.
I can import and use Tkinter just fine in my terminal under python3 as well as with IDLE3. However, when I try to import Tkinter in Visual Studio Code I get an "ImportError: No module named 'tkinter'.
The same issue was happening in Pycharm also but I had my interpreter set to the same as my terminal and not a project-specific interpreter.
I have tried the following:
import tkinter
from tkinter import *
try:
import tkinter
except ImportError:
import Tkinter as tkinter #Even though I'm using python3
None of this is working, Any idea why?
Also I am using Linux Mint.
I've been stuck with the same issue for weeks now where my VSC says there are no tkinter module but in shell and terminal it runs fine.
Solution: I found out that in the left buttom corner there is an interpreter that runs as Python 2 just click and select Python 3
In windows you could have selected to not install the needed tkinter components when python was installed (its optional in the installer).
Try running the installer again, and make sure these components are selected.
If your interpreter is PHP2 it is spelled "Tkinter" in the code. (uppercase)
If your interpreter is PHP3 then you should spell it like "tkinter"
When you were installing python there is a option. Install tkinter and ide just check it and then reinstall python after that close and open vs code. Here you go!
I use PyCharm 2016.2.3 (32-bit), Python 2.7.12 (32-bit), PyQt4-4.11.4-gpl-Py2.7-Qt4.8.7-x32, Windows 7 Home Premium.
I would be grateful for the procedure to link PyCharm to PyQT4. I'm not a techie.
I linked to the Python interpreter using File > Settings > Project Interpreter, by simply pointing to "python.exe"
For PyQt4, I can see the folder in
C:\Python27\Lib\site-packages\PyQt4
But which file do I actually "point to"?
Thanks.
Here's how I solved this for Python 2.7.12 and Python 3.4.4:
File > Settings > Project > Project Interpreter > <Python version>
Double-click setup tools
In Search, type PyQt4
In left pane, don't select PyQT4. This will give the error
Could not find a version that satisfies the requirement PyQt4
Instead, select PyQt4_windows_whl. For me, this was successful.
Test in editor by typing:
from PyQt4 import QtGui
As soon as I typed
from P
PyQt4 appeared in the dropdown.
As soon as I typed
from PyQt4 import Q
QtGui appeared in the dropdown.
I'm no expert, so I don't know if these tests are conclusive.
I ran the windows 64bit installer for PyQt4 pointing it to the python34 folder. Python is not in default location, so I added PYTHONPATH with D:\Program Files\Python34\Lib\site-packages\PyQt4
Added the import statement to my module: "from PyQt4 import QtGui". I execute and get: "from PyQt4 import QtGui ImportError: DLL load failed: The specified module could not be found."
I noticed that if I simply put import PyQt4 and use intellisense in IDLE there are only a few private methods visible.
Since I ran the installer, must I still perform a make? Readme references windows instruction that do not seem to be present on my machine.
I'm using PyCharm 2.5 on Ubuntu 11.10, trying to develop an application using PyGObject 3.0 on Python 3.2.2. I've installed the Ubuntu package python3-gobject, and when I run my code, it works exactly as expected.
However, PyCharm can not seem to find any of the PyGObject modules. It says Unresolved refrence: 'Gtk' when I hover over Gtk in my import statement, and of course none of the auto-completion works.
This is my code:
#!/usr/bin/env python3
from gi.repository import Gtk
win = Gtk.Window()
win.connect("delete-event", Gtk.main_quit)
win.show_all()
Gtk.main()
I've even tried making a python virtual environment and then installing PyGObject from source into it, and then even tried making symlinks from all the .py files in site-packages/gi/overrides to site-packages/gi/repository, all with no luck.
Any advice would be greatly appreciated!
Position the text cursor inside the redlined Gtk in:
from gi.repository import Gtk
hit Alt + Enter and choose "Generate stubs for binary module"
In Gtk+ 3 Python bindings to binary modules are generated dynamically using *.typelib databases. The dynamic importer for accessing all the modules is located in gi.repository. PyCharm cannot detect these modules using its code insight, because they require special handling.
I've filed a feature request for this issue: PY-6932. Feel free to vote for it.