Making pygtksourceview work in windows - python

So, I'm trying to get gtksourceview python bindings work under windows (I'm developing a cross platform gtk application that shows code, so gtksourceview seemed like a natural choice).
I have pygtk installed and working (I followed the instructions in http://www.pygtk.org/downloads.html)
I tried the instructions in http://projects.gnome.org/gtksourceview/ for gtksourceview.
Here is what I did:
Downloaded and extracted the latest gtksourceview window binaries from: http://ftp.gnome.org/pub/gnome/binaries/win32/gtksourceview/2.10/gtksourceview-2.10.0.zip
The website said gtksourceview needs libxml, so I downloaded and extracted the latest libxml window binaries from:
http://xmlsoft.org/sources/win32/libxml2-2.7.6.win32.zip
Added the folders containing dll files to the PATH (in my computer they were c:\opt\gtksourceview\bin; C:\opt\libxml2-2.7.6.win32\bin)
Installed pygtksourceview with the windows installer:
http://ftp.gnome.org/pub/gnome/binaries/win32/pygtksourceview/2.10/pygtksourceview-2.10.0.win32-py2.6.exe
Renamed the file libxml2.dll to libxml2-2.dll (after running depends on the gtksourceview dll)
Now, the gtksouceview widget seems to work, until I'm trying to set the code's language. When I do that python crashes.
Here is how I crash it in the console (the simplest way i could come up with):
>>>import gtksourceview2
>>>lang = gtksourceview2.language_manager_get_default().get_language('cpp')
>>>lang.get_style_ids()
I'm hoping I'm not the first person to use gtksourceview in python on windows. Any ideas what I should try?

So in case anyone else is wondering -- I grabbed the wrong libxml dll. The right one is in:
http://ftp.gnome.org/pub/GNOME/binaries/win32/dependencies/libxml2_2.7.7-1_win32.zip

Related

PyCharm Isn't Autocompleting OpenCV [duplicate]

I cannot get autocomplete working for OpenCV (Python) on Windows.
According to Abid's instructions here, I pasted the cv2.pyd file in the C:\Python27\Lib\site-packages.
In the Python code, I import as follows:
import cv2.cv as cv
I have also installed numpy, and it created its own folder in site-packages unlike OpenCV (which I've pasted directly into site-packages).
With this setup, the code executes without any problems, even when OpenCV methods are called.
But I have not been able to get autocomplete to work. I have tried to get it to work on Sublime Text 2 (with SublimeCodeIntel) and PyCharm. In both IDEs, autocomplete works for the numpy import, but fails for the OpenCV import.
I'm using OpenCV 2.4.6, and Python 2.7 (32 bit).
Any possible solutions?
The reason it's not working is because you're using a .pyd file, which is essentially the same as a compiled .dll. Autocomplete works by reading the source .py files, which are plain text. Try installing the OpenCV and Intel Math Kernel Library optimized NumPy packages from Christoph Gohlke's Python Extension Packages for Windows repository, which is frequently updated and a must-use resource for anyone who does any kind of scientific Python computing on Windows. Make sure you delete the cv2.pyd and numpy directories from site-packages first. These new packages will install the .py source files needed by the autocomplete engine in Sublime Text.
EDIT
OK, so I wrote the above because it worked well for a bunch of other packages. I'm a Python 3 guy, and I never installed OpenCV from Gohlke because it only has Python 2 bindings. After reading #CrazyCoder's comment below, I booted up Win7, and indeed he's absolutely correct (and I should have realized this before) - since OpenCV is written in C/C++, the only .py file included in the Gohlke package is cv.py, whose entire contents are as follows:
from cv2.cv import *
The rest is contained in cv2.pyd and a bunch of .dlls. The full OpenCV Windows distribution from opencv.org is a 291 MB download, which expands to 3 GB, and the few .py files in there are involved in building OpenCV, and aren't any good for autocomplete purposes. So, unfortunately, I don't know if there's a solution to your problem at the moment. Just keep the docs handy, and perhaps check out OpenCV Computer Vision with Python from Packt/O'Reilly, published in April 2013.
I've had the same issue with PyCharm when building a custom version of OpenCV on windows. Here is what I did to fix it:
OpenCV made a folder in Python site-packages like so:
opencv site-packages
So what you need to do is just add the python-3.9 folder to your interpreter.
File
Settings...
Python interpreter
Three dots icon next to your interpreter -> Show all...
Select your interpreter and click on the "Show paths for selected interpreter" icon
Add the folder inside the cv2 site-packages
Now import the cv2 module normally.
The best way to solve all the problems of OPENCV-PYTHON is by uninstalling it and reinstalling it.
Even I faced the same problem.
I fixed it by:
python -m pip uninstall Opencv-python
Then I reinstalled it by using a lower version. But unfortunately, I did not know the versions of opencv; So by using a small trick you can get it by running:
python -m pip install opencv-python==
and you will get an error similar to this:
ERROR: Could not find a version that satisfies the requirement opencv-python== (from versions: 3.4.0.14, 3.4.10.37, 3.4.11.39, 3.4.11.41, 3.4.11.43, 3.4.11.45, 3.4.13.47, 3.4.15.55, 3.4.16.57, 3.4.16.59, 3.4.17.61, 3.4.17.63, 4.3.0.38, 4.4.0.40, 4.4.0.42, 4.4.0.44, 4.4.0.46, 4.5.1.48, 4.5.3.56, 4.5.4.58, 4.5.4.60, 4.5.5.62, 4.5.5.64) ERROR: No matching distribution found for opencv-python==
Here you can see all the versions of opencv-python; choose any one (but not the latest as the error occurs due the latest version of opencv-python. install it by using:
pip install opencv-python==3.4.17.61 (You can choose your version, but this version solved the issue for me)
then enjoy your coding....
Even AUTO-COMPLETE error in opencv-python gets solved.
HAPPY CODING

Tcl version not recognized in Anaconda/Spyder/Python 3.8.5

I installed in Anaconda the tk package which is 8.6.10. I run Python 3.8.5
When I run within Spyder IDE the simple script
import tkinter as tk
win = tk.Tk()
I got the classic message "TclError: Can't find a usable init.tcl in the following directories:"
In the list of directories reported I do have tcl.
I tried in the cmd from anaconda to run tclsh and wish and they are both working. By running wish and looking for the version it reports correctly Tcl and Tk 8.6.10
So I took the C:\ProgramData\Anaconda3\Library\lib\tcl8.6\init.tcl and moved it in C:/ProgramData/library as this is one of the directories I get in the error report.
When I do this I got another error "C:/ProgramData/library/init.tcl: version conflict for package "Tcl": have 8.6.9, need exactly 8.6.10"
So it is clear that the tclsh in bin and the init.tcl are not from the same version (why?) but how can now enforce a correct behavior of my python script looking for the right Tcl/Tk?
I was expecting this to work out of the box
p.s. THe directory "C:\ProgramData\Anaconda3\Library\lib\tcl8.6" is also in the list of directories that is returned by the error.
The problem is that the version of the DLLs that are being used (which might be TCL86.DLL and TK86.DLL on Windows, but the exact names can vary) must match exactly the version of their support files (the primary one is init.tcl, but there's a lot more besides). That's a hard requirement; the software checks it (rightly!) and definitely won't work without them. As the binary code is looking for the files from 8.6.9 and yet has the files from 8.6.10 (a version mismatch) it's not going to work. (I don't know exactly how Tkinter was built.)
But at least we know what files it is looking for, and exactly where to get them. The official release of Tcl and Tk 8.6.9 is at https://sourceforge.net/projects/tcl/files/Tcl/8.6.9/ so get tcl869-src.zip and tk869-src.zip from there, and copy the contents of the library directory in each ZIP to where you want them to be (presumably one of the directories that are searched for). You don't need to do anything fancier than that, except perhaps to delete the old mismatched files if they're earlier on the path.

Matlab error: Not find Qt plataform plugin 'windows'

I'm running a python function in Matlab and when I run I got the error:
This application failed to start because it could not find or load the
Qt plataform plugin 'windows' in '' '' , Available plugins are:
minimal offscreen, windows. Reinstalling the application may fix this
problem.
I already followed the steps in this video copying the platform folder to pyqt tools and in this post add to the environment path.
If I run my code in python it works fine, It seems that Matlab is not finding the Qt platform plugin 'Windows'
Someone can help me, please?
This is the problem of deploying Qt applications. Depending on platform you're using you can find tool for deploying, it is in Qt directory. For example, on my PC with Windows this is:
c:\Qt\5.15.0\mingw81_64\bin\windeployqt.exe
You can call this tool like this:
windeployqt <path-to-app-binary>
// OR
windeployqt --qmldir <path-to-app-qml-files> <path-to-app-binary>
There are many other options like --debug, --release, etc. Too see all of them, just call windeployqt.
On other platforms it could be linuxdeployqt, macdeployqt, also pyqtdeploy.
After calling this tool it will copy all required submodules to (near) your app, so it will find all it needs.
On my Windows system, I had the same experience that the Python function ran natively, but would not run via MATLAB. The problem was missing or incompatible dlls (not exe) files. To solve the problem I copied the exact dlls from my conda environment into the MATLAB \bin\win64 folder. That is, I copied these five dlls
qdirect2d.dll
qminimal.dll
qoffscreen.dll
qwebgl.dll
qwindows.dll
from the \Library\plugins\platforms folder of my conda environment
C:\Users\username\AppData\Local\Continuum\envs\myenv\Library\plugins\platforms
into the MATLAB folder
C:\Program Files\MATLAB\R2020b\bin\win64\platforms
While doing the copy, I overwrote three dlls which already existed in the MATLAB folder.

How to install FontForge Python plugin for Windows

I need some help with installation of FontForge Python on Windows.
I am trying to get ffpython to be usable across the whole system by
adding appropriate entried from fontforge-console.bat
redirecting the Python Path to FontForge installation path
The console said that Python is missing .dll files and I do not know what happened.
I tried searching for installation that comes with Python installation and came up nothing. THe documentations are too old and didn't give enough information to build my own. Current version is 2019-08-01 on Windows 10 1909. Please give any pointers on how to install FontFoge Python module.

"R6034 An application has made an attempt to load the C runtime library incorrectly" after pygtk being installed

I'm using python 2.7.9 and encountered a problem when installing pygtk.
It displayed "Runtime error!...R6034 An application has made an attempt to load the C runtime library incorrectly" when installing numpy/scipy after pygtk being installed.
I tried to figure it out by searching it in stackoverflow and found two similar questions: Runtime error R6034 in embedded Python application and An application has made an attempt to load the C runtime library incorrectly.
So following the first one, I deleted the path corresponding to msvcr90.dll, however, it still cannot work. Then I chose to simply delete msvcr90.dll; at this time, this error wasn't presented when installing numpy/scipy, however, these two modules cannot work when simply typing "importing numpy/scipy".
I also renamed gtk-2.0 following the second one. Then numpy and scipy can be successfully installed. But it displayed "Error processing line 3 of C:\Python27\lib\site-packages\pygtk.pth" when installing matplotlib using pip.
I'm really confused about it. Can anybody provide some methods to fix it?
I've installed Python and PyGTK on 5+ machines, at least two of them brand new, clean builds of Win 7.
I've got the An application has made an attempt to load the C runtime library incorrectly error whenever I install a Python package as a windows installer (rather than using pip) on all these machines. It's annoying, but has never made a jot of difference, both Python and Gtk function correctly.
You've deleted msvcr90.dll, and that is why you get your Error processing line 3... If you look at this file, you'll see that line 3 is import runtime, and if you look further into the 'runtime' package, you'll see that this then tries to find the missing dll.
I think your best bet is to try to restore the missing file. If it's still in your recycle bin - great!
If not, the best thing to do is reinstall the Visual C++ runtime library
I made this video to show my way: https://www.youtube.com/watch?v=s6jhR1VBfeU. I use Anaconda to embedded Python in my C++ application. I simply changed "msvcr90.dll" to "msvcr90.dll_hihi" in 3 folders:
C:\Users\your user\Anaconda2\Library\bin, C:\Users\your user\Anaconda2 and C:\Program Files\Intel\iCLS Client (for x64)

Categories

Resources