I did use the following command in my terminal:
sudo dnf install gtk4-devel
I did get the message below:
[sudo] password for XXXXXXXXXXXXX:
Last metadata expiration check: 1:26:27 ago on Wed 12 May 2021 07:08:28 PM CDT.
Package gtk4-devel-4.2.1-1.fc34.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!
When I try to run a scrip (script to get machine information like screen size) that make use of gtk, and use to work before I switch from ubuntu18 to fedora33 (now 34) I do receive the following message
Traceback (most recent call last):
File "/usr/lib64/python3.9/idlelib/run.py", line 559, in runcode
exec(code, self.locals)
File "/run/media/xxxxxxxxxx/FreeAgent Drive/01ArchivosDeBusqueda/xxxx/Proyectos/Buscador/Codigo/Codigo_de_Ejemplos/monitores.py", line 18, in <module>
import gtk
ModuleNotFoundError: No module named 'gtk'
So I decided to run
python3 -m pip install gtk4
getting the following message
Defaulting to user installation because normal site-packages is not writeable
ERROR: Could not find a version that satisfies the requirement gtk4 (from versions: none)
ERROR: No matching distribution found for gtk4
If using sudo dnf install is telling me that the module is already installed, how should I import it to my script: use import gtk or import gtk4 (neither work) or import?
if I type which gtk or which gtk4 it does tell me there is no module gtk
which gtk
/usr/bin/which: no gtk in (/home/xxxxxxxxxxxxxxxxxxxxx/.local/bin:/home/xxxxxxxxxxxxxxxxxxxxxx/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/var/lib/snapd/snap/bin:/opt:/opt)
which gtk4
/usr/bin/which: no gtk4 in (/home/xxxxxxxxxxxxxxxxxxxx/.local/bin:/home/xxxxxxxxxxxxxxxxxxxxx/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/var/lib/snapd/snap/bin:/opt:/opt)
So is the module installed or not? How can I verify that, if not how can I install the gtk4
what does it mean “Defaulting to user installation” I am the only user of this machine
what are “normal site-packages”
Is this condition related to permissions, if yes how to fix it for it does not happen again?
I do appreciate any help, please consider I know nothing about computers, computer systems or programing.
Related
I ran into some problems with some pip installations. I have found a way of installing that works, but I feel like it's wrong.
I installed pygame from the cmd prompt and got this message:
Defaulting to user installation because normal site-packages is not
writeable Requirement already satisfied: pygame in
c:\users\Somenewguy\appdata\roaming\python\python310\site-packages
(2.1.2)
But when I went to pycharm and started my project, I got this message:
Traceback (most recent call last):
File "C:\Users\Somenewguy\Python Projects\new\main.py", line 1, in <module>
import pygame
ModuleNotFoundError: No module named 'pygame'
I then did the pygame pip installation from the terminal in pycharm. But this time I installed it directly into the project folder, and that approach worked.
This is the only way I can import pygame into my projects which I think is weird.
Why do I have to install this package for each project?
If you use a virtual-environment, this is the expected behavior. If you don't want to install it every time, use the system environnement.
I am using python3 with the Thonny IDE. My programs are running on a Raspberry Pi 4B.
I tried to install PyBluez on different ways, with pip and with the built-in package installer of Thonny. Every time the installation seemed to work. When I then tried to import the module via import PyBluez I always get this error message:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pybluez'
But when I try to install it again I get these message, what I think mean, that it is already installed:
Requirement already satisfied: pyserial in /usr/lib/python3/dist-packages (3.4)
And the built-in package installer of Thonny shows me this message:
Installed version: 0.23
Installed to: /home/pi/.local/lib/python3.7/site-packages
Latest stable version: 0.23
Summary: Bluetooth Python extension module
Author: Albert Huang
Homepage: http://pybluez.github.io/
PyPI page: https://pypi.org/project/PyBluez/
Requires: pyobjc-core (<6,>=3.1), pyobjc-framework-Cocoa (<6,>=3.1), gattlib (==0.20150805) ; extra == 'ble'
But I still get the error that there is no module with this name.
I also tried to install the package PySerial on the same ways, but I ran into the same problem as with PyBluez. So it might be a general problem?
I haven't personally worked with that module, but after looking at the GitHub documentation, I can see that the import statement that is used is import bluetooth.
For example, on this page that's what they have
import bluetooth
import bluetooth._bluetooth as bluez
Consider using a different import statement
When I try to run a bot, I get this error message in the terminal:
zass#zass-system-product-name:~/python-telegram-bot/examples$python
echobot.py
/usr/local/lib/python2.7/dist-packages/python_telegram_bot-8.0-
py2.7.egg/telegram/utils/request.py:38: UserWarning: python-telegram-
bot wasn't properly installed. Please refer to README.rst on how to
properly install.
Traceback (most recent call last):
File "echobot.py", line 8, in <module>
import telegram
File "build/bdist.linux-x86_64/egg/telegram/__init__.py", line 94, in
<module>
File "build/bdist.linux-x86_64/egg/telegram/bot.py", line 34, in
<module>
File "build/bdist.linux-x86_64/egg/telegram/utils/request.py", line
33, in <module>
ImportError: No module named ptb_urllib3.urllib3
I'm running Python 2.7 on ubuntu, git and telegram bot are installed. - How can I fix it?
First of all make sure you have urllib3 installed. Sometimes urllib3 installation breaks. If for some reason your install of urllib3 is failing to include the util submodule, you could simply download the archive from the pypi page and copy the util folder from there to your urllib3 install location.
You may also issue the command below to get an up-to-date version:
sudo pip install urllib3 --upgrade
Then, see where your module is by starting a python interpreter and check where the urllib3 module is being loaded from:
python -c "import urllib3; print urllib3.__file__"
If all the above didn't work for you, make sure you're importing it right! and make sure there is no conflict.
If you clone the python-telegram-bot repo you need to run the following command before installing the code:
git submodule update --init --recursive
Then install the code with python setup.py install
Maybe you have 2 version of python and default version is 3.x
Try to check version of python
python -V
if default version is 3 then run your code with python version 2.
python2 echobot.py
it can be python2 or python2.7
Also it can be cause of versions of libs
I try to import glib in Python (2.7) and get the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/share/pyshared/glib/__init__.py", line 22, in <module>
from glib._glib import *
ImportError: No module named _glib
Seems as if glib is found, while _glib is not found.
Has anybody a hint for solving this problem? I'm running Ubuntu and installed python2.7, python-gobject, python-gda, dbus from Ubuntu's package manager.
I had this issue.
You can try moving the glib and related folders out of the python2.7 install locations e.g. on ubuntu /usr/shared/pyshared in case these have been installed wrongly.
Then remove and reinstalling the related packages with the platform package manager ...
sudo apt-get remove
followed by sudo apt-get install
for ...
python-gobject python-gtk libglib2.0-dev python-cario python-gi
since if they are present in pyshared I found that they were not probably reinstalled
I run ubuntu 10.04, with its native python 2.6.6 and GCC 4.4.5, and an "import glib" in python appears to work.
I installed "python-numpy", "python-matplotlib" and "python-pyfits" with the synaptic package manager and nothing else, in particular nothing installed from a more recent version found on the package's site because previous experience learned me this was usually a very bad idea.
But I have NO /usr/share/pyshared/glib/ folder and do not know how you get it.
Is this folder on your path or PYTHONPATH ?
If yes, try to remove it from the path and retry the "import glib", it is possible that you get some second installation of glib in that place (installed - and maybe needed - by another package).
glib is an interface to the c compiler, so it is used in several places. What is your GCC version ? GTK also makes intensive use of glib. Did you installed "GTK" and "pygtk" from the synaptic or did you did it on the hard way, with all separated little packes to be compiled ? If yes, try to install it from the synaptic.
I mostly think this comes from some installation mix of some python extension somewhere. The radical solution, of course, is to reformat the computer with a fresh O.S., but it's probably something you do not want, so I should try to uninstall all packages python uses, and re-install them from the synaptic.
Hope this helps...
I installed a new module and it appears as if one of its dependencies was not already installed. The module is called Xlib.display.
Here is the error message I received:
from Xlib.display import Display
ImportError: No module named Xlib.display
Where can I find this module that I am apparently lacking? Google yielded no leads.
"Edit: I already have that sourceforge module downloaded but I still get the same results.
Please try.
This shall install Xlib
sudo apt-get install python-xlib
Then you can check
>>from Xlib.display import Display
To install PyMouse if you want to control and capture mouse events please use:
sudo easy_install https://github.com/pepijndevos/PyMouse/zipball/master
Below worked for me!
pip install python3_xlib
I have also used pyuserinput for automation which requires this.
I was having the same problem, but the solutions above didn't work for me. Since I had installed python through the anaconda package, when I used:
sudo apt-get install python-xlib
Xlib was still undetectable by python2. The solution in my case was to use:
anaconda search -t conda python-xlib
Then find the package from the anaconda api, mine was erik/python-xlib. Install it using:
conda install --channel https://conda.anaconda.org/erik python-xlib
Then it worked.
On Debian systems install python-xlib.
On other systems there's a high probability that the package carries the same name.
I don't think the Xlib library works in Python 3.
Source:
Requirements
The Python X Library requires Python 1.5.2 or newer. It has been tested to various extents with Python 1.5.2 and 2.0 through 2.6.
I honestly cant explain why this works... but here is the command that got it working for me.
sudo apt-get install python3-xlib
Should not work because xlib apparently does not work with python 3.x, but everything installed alright, so I'm not complaining!
I was looking for the same answer, however after some more digging it seems that XCB (X protocol C-language Binding) will obsolete Xlib in general. From the XCB website:
The X protocol C-language Binding (XCB) is a replacement for Xlib featuring a small footprint, latency hiding, direct access to the protocol, improved threading support, and extensibility.
Fortunately there are python bindings available as python-xpyb in apt or xpyb on PyPi. I've not gotten that far in my project so I haven't tested if this works with Python3, but this is probably the way to go and the proper place to file any Python3 support bugs if necessary.
Scenario:
I was trying to use screenshot functionalities of pyautogui package. I was getting this error:
Traceback (most recent call last):
File "test_screenshot.py", line 1, in <module>
import pyautogui
File ".../miniconda3/envs/myenv/lib/python3.7/site-packages/pyautogui/__init__.py", line 152, in <module>
from . import _pyautogui_x11 as platformModule
File ".../miniconda3/envs/myenv/lib/python3.7/site-packages/pyautogui/_pyautogui_x11.py", line 7, in <module>
from Xlib.display import Display
ModuleNotFoundError: No module named 'Xlib'
Python code (test_screenshot.py):
import pyautogui
img = pyautogui.screenshot('test.png')
Environment:
Ubuntu 16.04 (LTS)
conda 4.5.11
Python 3.7 (Miniconda)
requirements.txt:
certifi==2019.3.9
Pillow==5.4.1
PyAutoGUI==0.9.42
PyGetWindow==0.0.4
PyMsgBox==1.0.6
PyRect==0.1.4
PyScreeze==0.1.20
PyTweening==1.0.3
Solution:
I installed python-xlib package in the conda environment using:
pip install python-xlib
Now test_screenshot.py is running without any error.
Updated requirements.txt:
certifi==2019.3.9
Pillow==5.4.1
PyAutoGUI==0.9.42
PyGetWindow==0.0.4
PyMsgBox==1.0.6
PyRect==0.1.4
PyScreeze==0.1.20
python-xlib==0.25
PyTweening==1.0.3
six==1.12.0