Struggling to install pygtk with pip - python

I am trying to install pygtk using pip on Windows. Initially i get an error saying
"ERROR: Could not import dsextras module: Make sure you have installed pygobject."
So when I try installing pygobject I get an error saying
"ERROR: Could not find pkg-config: please check your PATH environment variable"
Pretty new to Python so could be making a stupid mistake but does anyone have any ideas?
Thanks

I had the same problem on my Window 7 machine, and solved it by installing the prebuilt PyGTK executables, which I found here: http://ftp.gnome.org/pub/GNOME/binaries/win32/pygtk/2.22/.
I installed the "pygtk-all-in-one-...." for my version of Python (2.7).

Related

Pycharm: import Serial is NOT working but i already did "pip3 install pyserial"

i am quite trouble why my pycharm does not recognize import serial. i am doing python code but i need to use Serial. so just from what i found:
i need to go to CMD, then enter "pip install pyserial" or "pip3 install pyserial"(this is what i did).
after that the installation seems successful, i didnt see any errors
after that. i went back to my Pycharm and type import serial or import pyserial
despite that, both code are not working...
i wonder what is the problem with my Python?
-Windows 10
-Python 3.10
-Pycharm Community Version: 2021.2.3
I had the same problem since I started using python 3.10.
I found that you have to download the complete pyserial package from github, unzip the entire package and edit the setup.py file and add the line 'Programming Language :: Python :: 3.10',
and then from the CMD window run python setup.py build
With that it works !!!
Just open the terminal within the Pycharm IDE and use pip to install on there.
Try uninstalling it from pip and then using the Python Packages tab to install it. It worked for me when I tried that.

django OSError: no library called "cairo" was found on windows

When I run the Django server, I see this problem !!
OSError: no library called "cairo" was found
no library called "libcairo-2" was found
cannot load library 'libcairo.so': error 0x7e
cannot load library 'libcairo.2.dylib': error 0x
cannot load library 'libcairo-2.dll': error 0x7e
Installing GTK+ didn't work for me.
I solved this problem using UniConverter2.0.
My environments is
Python 3.7
Windows 10 x64
Install uniconvertor-2.0rc4-win64_headless.msi,
Find the "dll" sub-directory under the UniConverter installation path.(In my case, C:\Program Files\UniConvertor-2.0rc4\dlls)
Add this "dll" path to the system path.
Close VSCode and reopen the project.
Try to run the server again.
Enjoy!
WeasyPrint needs the Pango, cairo and GDK-PixBuf libraries. They are part of GTK+ (formerly known as GIMP Toolkit), and must be installed separately.
After installing GTK+ libraries, do :
python -m weasyprint http://weasyprint.org weasyprint.pdf
Starting from Python 3.8, dll's need to be added separately.
Added GTK+, MSYS2, Visual Studio C Compiler and Uniconverter. But, nothing seemed to work.
Finally, got it working after putting the script for calling add_dll_directory.
import os
def set_dll_search_path():
# Python 3.8 no longer searches for DLLs in PATH, so we have to add
# everything in PATH manually. Note that unlike PATH add_dll_directory
# has no defined order, so if there are two cairo DLLs in PATH we
# might get a random one.
if os.name != "nt" or not hasattr(os, "add_dll_directory"):
return
for p in os.environ.get("PATH", "").split(os.pathsep):
try:
os.add_dll_directory(p)
except OSError:
pass
set_dll_search_path()
Source: PyCairo Windows Python3.8 Import Issue
See the solution here:
https://www.programmersought.com/article/47674569357/
You will need to add a path if not added after installations:
C:\Program Files\GTK3-Runtime Win64\bin
I have been solving it many times this way.
If you are using a lightweight Linux Docker Image, it may not include GTK as said above, then, you can include it by adding in your Dockerfile
RUN apt-get update -y
RUN apt-get install python3-cffi python3-brotli libpango-1.0-0 libharfbuzz0b libpangoft2-1.0-0 libgtk-3-dev gcc -y
Where all those packages are recommended to be installed by weasyprint and GCC has the GTK.
Ok I figure this out. you can have a 64 bit version of python that doesn't work. What I have found to work and this could change is the installing the 64 bit version of python from python's website, not from the Microsoft store!
remove any version of python you have installed
download https://www.python.org/ftp/python/3.8.10/python-3.8.10-amd64.exe
install
download and install https://github.com/tschoonj/GTK-for-Windows-Runtime-Environment-Installer/releases
exact link is https://github.com/tschoonj/GTK-for-Windows-Runtime-Environment-Installer/releases/download/2021-04-29/gtk3-runtime-3.24.29-2021-04-29-ts-win64.exe
note that link is from https://doc.courtbouillon.org/weasyprint/stable/first_steps.html#windows
add bin folder from that (sorry it was somebody else's machine, I use Ubuntu) in your environment path.
run through the first steps on weasyprint and you should be good to go!
Might be a bit late, but I just encoutered the same issue and:
Start here: https://weasyprint.readthedocs.io/en/stable/install.html#windows. Where you will find the links for the GTK Pack that contains the required DLLs.
In my case, I have a 64bit Python, so i use: "Download and run the latest gtk3-runtime-x.x.x-x-x-x-ts-win64.exe"
I did not change the installation directory
Once the installation is completed. I added the path to my variable paths.
I restarted the terminal, made sure I could locate the DLLs with : WHERE libcairo-2.dll. This retured C:\Program Files\GTK3-Runtime Win64\bin\libcairo-2.dll
Then I run python -m weasyprint http://weasyprint.org weasyprint.pdf
and got a few WARNINGs but they are just warnings :)
I have faced same error as well
I haved installed gtk as followed as gtk install in windows
Nothing worked
After that :
python -m pip install pycairo
solved the problem for me
Try this: https://cairocffi.readthedocs.io/en/stable/overview.html#installing-cairo-on-windows
And maybe this will work to: https://www.lfd.uci.edu/~gohlke/pythonlibs/#pycairo
Best option is instal cairocffi trough pipwin
pip install pipwin
pipwin install cairocffi

Tkinter was installed with Python 3.6.0 but is now not importing and cannot pip install/uninstall (Windows 7)

I remember the dialog box prompting me with a checklist which included Tkinter. I did not uncheck the box. This is the first time I have tried to import Tkinter after this install and get the standard "module not installed" error.
When I go to install using pip install Tkinter I get a message saying that it could not find a version that satisfies the requirement. No matching distribution found.
If I don't have to re-install Python that would be great, has anybody ever encountered this before/know what could cause this?
Uninstall your python ans install the new Python 3.7.2 on the official website !
Your packtage will be complete !
If it's still bot work, try to change the path of installation.

I cannot install dipy library for python, why ? In the description I explain what I did

I went to http://nipy.org/dipy/installation.html and install nibabel, then I when I wanted to install dipy, there where 2 problems:
Wheel was not built
and vcvarshall.bat not found.
What I did ?
Install Setuptools in site-pakcages
download Setuptools-34.3.1-py2.py3-none-any.whl (md5) and save in site-packages
I also try
python setup.py install --compiler=mingw32รง
and
If you get an error saying unable to find vcvarsall.bat then you need to create a file called pydistutils.cfg in notepad and give it the contents
[build]
compiler=mingw32
But setup.py de system it did not find, and I still have vcvarshall.bat not found.
what I need to do?
I am using, Windows 7, Python 3.5.1 and Anaconda 2.5.0 (64 bit)
You will almost certainly find it easier to install third-party packages if you adopt virtual environments. When done correctly you will then not need admin privileges to install packages into virtualenvs. The HitchHikers' Guide to Python contains more information about this.
The vcvarsall.bat is, I believe, a part of the Visual Studio (the Express version is available at no cost) environment. It's required when you are trying to build a compiled Python extension as described in this article. I'm not sure how that will play with mingw.
So, I installed via ANACONDA but , when I go to python, and I want to import dipy it says: No modle named dipy
Solved ! Well I had python 3.5 and dipy has some issues with that version, so I installed Anaconda with python 2.7 , installed visual c++9 and follow the steps on the web !

PyHook on python 3.5

I am trying to write a basic keylogging program on python. I need to install the pywin32 and pyhook modules. I have managed to get pywin32 installed, but cannot seem to pyhook to work. I have read its possible to get it to work on later versions of python, but cannot seem to figure it out. I have tried both .exe and .whl installs. Using whl in cmd gives error that the wheel is not supported. Does anyone have a solution to install pyhook on python 3.5. Thanks
This is how I did it...
Download the py hook module that matches your version of python from here. Make sure that if you have python 32 bit you download the 32 bit module (even if you have windows 64x) and vice versa.
Open your command prompt and navigate to the folder where you downloaded the module
Type "pip install " and then the name of the file.
Ex: "pip install pyHook-1.5.1-cp27-none-win32.whl"
Note : you need pip
If your pip install have not success.
Try -> when you download a pyHook-1.5.1-cp27-none-win32.whl file from http://www.lfd.uci.edu/~gohlke/pythonlibs/#pyhook
After that move file to Programs\Python\Python35-32\Scripts path
and then pip install pyHook-1.5.1-cp27-none-win32.whl
I hope my answer is useful for you.

Categories