PyQt4 can't import Qsci - python

I'm installing PyQt4 on an old Linux system (CentOS 4.4) that can't be upgraded for hardware compatibility reasons. I've got Python 2.6, QT4 and SIP installed, and the installation of PyQt4 didn't give me any errors.
When I run Python, this happens:
Python 2.6.2 (r262:71600, May 11 2011, 14:18:37)
[GCC 3.4.6 20060404 (Red Hat 3.4.6-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import PyQt4
>>> import PyQt4.Qsci
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named Qsci
I looked around, and found /usr/local/lib/python2.6/site-packages/PyQt4/uic/widget-plugins/qscintilla.py, which is almost empty of non-comment stuff:
pluginType = MODULE
def moduleInformation():
return "PyQt4.Qsci", ("QsciScintilla", )
Any ideas?

You need to install qscintilla separately. If PyQt is already installed, then you should just have to install the qscintilla python bindings. Hopefully this fixes your issue!

Related

How to install tkinter for python3.10.6 on CentOS7?

First, I installed openssl 1.1.1q package using the following source on CentOS7.
(https://www.openssl.org/source/openssl-1.1.1q.tar.gz)
Second, I installed tcl/tk packages using the following sources.
(https://prdownloads.sourceforge.net/tcl/tcl8.6.12-src.tar.gz
https://prdownloads.sourceforge.net/tcl/tk8.6.12-src.tar.gz)
Finally, I installed python 3.10.6 using the following source.
(https://www.python.org/ftp/python/3.10.6/Python-3.10.6.tar.xz)
However, I can't use tkinter module.
For example, when I import tkinter I get the bellow message.
Python 3.10.6 (main, Aug 18 2022, 11:15:38) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tkinter
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.10/tkinter/__init__.py", line 37, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ModuleNotFoundError: No module named '_tkinter'
The yum doesn't support the python 3.10.x version. How can I resolve this problem without yum?
What should I do to use tkinter?
You are importing tkinter in a wrong way, it is like this
import tkinter
tkinter is a preinstalled library in python, to test it open cmd and type
python -m tkinter
a small window should appear, if it does then it is working

distutils.spawn not available unless imported

I have distutils installed and it works in some cases. However when trying to use a submodule it won't import unless I explicitly import it.
$ python
Python 3.8.5 (default, Jul 21 2020, 10:42:08)
[Clang 11.0.0 (clang-1100.0.33.17)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import distutils
>>> distutils.spawn
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'distutils' has no attribute 'spawn'
>>> from distutils import spawn
>>> distutils.spawn
<module 'distutils.spawn' from '/usr/local/Cellar/python#3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/distutils/spawn.py'>
I'm on Mac and have tried inside a venv and outside of one. I have a dependency that calls distutils.spawn.find_executable('python3') and isn't working.
This is perfectly normal. This is how Python import works. Unless distutils/__init__.py imports .spawn itself (which it doesn't do) you have to import it yourself to make it available. Importing just distutils is not enough to access submodules.
Counterexample: import os makes os.path automatically available but that's because os.py makes it available for you.

How to import a package that use absolute import in python

I'm trying to import volatility3 into my python project/script, so that I don't have to use os.system since volatility3 is already made in python3.
I'm wondering how can I import all the functions/modules of said project ? The functions I'm interested in are located in volatility3/volatility/framework
I tried simply putting:
>>> import volatility3.volatility.framework
But I get the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/volatility3/volatility/framework/__init__.py", line 12, in <module>
from volatility.framework import constants, interfaces
ModuleNotFoundError: No module named 'volatility'
My guess is I have to modify sys.path or one of the path variables but this does not seem to work.
Thanks,
The best solution here would be to properly install volatility with pip3, from your already exiting repository folder:
$ pip3 install /home/volatility3
or directly from pipy (not tested):
$ pip3 install volatility3
then you should be able to import the from volatility package directly:
Python 3.6.9 (default, Nov 7 2019, 10:44:02)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import volatility.framework
>>> volatility.framework
<module 'volatility.framework' from '/home/bruno/.local/lib/python3.6/site-packages/volatility/framework/__init__.py'>
>>>

salesforce python Beatbox import error

I am trying to log in to salesforce.com's sandbox using a URL, ID and PASS. I want to use SOAP API for that. When I try to import beatbox in python3, it throws an ImportError exception. However, I can confirm that beatbox is installed in python3. So what am I doing wrong? Is there any other way to do it?
Python 3.5.0 (default, Dec 6 2015, 17:23:12)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-16)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import beatbox
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/site-packages/beatbox-32.1-py3.5.egg/beatbox/__init__.py", line 1, in <module>
ImportError: No module named '_beatbox'
>>>
The beatbox module that you probably installed is this : Beatbox 32.1.
Solution 1 : The above beatbox module only supports python 2.x (tested with python 2.7). So, switch to Python 2.x if that is an option.
You can find the source by original author of beatbox here and it has been updated to support python3.
Solution 2 :
Clone the repo in your local machine using git clone https://github.com/superfell/Beatbox.git
Change to the Beatbox directory
Install the module using python setup.py install
For me the issue was I had both beatbox and beatbox3 installed.
beatbox3 is the version for python3.
Once I uninstalled beatbox it worked fine.

PyQt4 Missing in import statement

I tried to download PyQt4 however it no lomger appears to be available, so I downloaded the nearest thing to it that I could find PyQt-win-gpl-4.8.4. The problem is when I try to follow the examples in "Rapid GUI programming with Python and QT" i cannot use some of the imports e.g. from PyQt4.QtCore import * gives me the following Error (copied from IDLE):
Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
`import sys
`import time
`from PyQt4.QtCore import *
**Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
from PyQt4.QtCore import *
ImportError: DLL load failed: The specified procedure could not be found.
>>>**
You downloaded a source package, so you'd have to compile everything. Try the binary package at the bottom of Riverbank's page. As you have python 2.7 on a 32bit system, you want to download PyQt-Py2.7-x86-gpl-4.8.4-1.exe.
As far as I know you could just intall pyqt4 with either:
pip install pyqt4
or
easy_insatll pyqt4
or
http://www.riverbankcomputing.co.uk/software/pyqt/download
-> under Binary Packages choose the one that correspondends to your python version and system
for you this schould be the right one: pyqt4 py2.7 32bit

Categories

Resources