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
I am working on an embedded linux system and try to get python-wand running...
But i am not able to install anything on this system so i included them in the lib folder of my application (this folder will be linked to the system).
Its not possible to update the glibc version of the system.
To test if its working i am using:
from ctypes import *
cdll.LoadLibrary('libMagickWand-6.Q16.so.6')
This will throw:
OSError: /lib/libc.so.6: version `GLIBC_2.17' not found (required by
../libMagickCore-6.Q16.so.6)
So is it possible to build ImageMagick with a different glibc version packed ?
I am new to compiling but this should work if i can change glibc only for ImageMagick.
Is it possible if i compile ImageMagick with a older version of glibc ?
Is the compiled code affected by the gcc / glibc version ?
Finally i got this running on my embedded system:
Get same glibc/eglibc version on the cross compile system.
Compile imagemagick with this glibc version.
Don't forget to install libpng for png support...
Note:
If you want to use imagemagick combined with ghostscript to convert
pdf -> images don't forget that ghostscript is licensed under AGPL and
you cannot use this in your product unless you are using the same license, or buy the license....
You may set the LD_LIBRARY_PATH to your path (./lib) before starting python.
If it's a headless system you may write a shell script besides your python script to set the variable right before starting the python and then start python. Then use that script in your autostart code.
Question:
I want to compile a third-party library like Pillow or Numbpy but I want to change the name of the python27.dll to corepython27.dll. How do I do this during the compile process? Is it something I need to change in the setup.py? Or the distutils library?
I should explain that I have no experience in compiling at all. I just know that I will need to make this change as I learn more about the basics of compiling.
Explanation:
Corel's PaintShop Pro uses an embedded python interpreter to run scripts inside the program. And I would like to be able to use third-party libraries like pillow and numpy but they always fail to load. The version of python that is included with PaintShop Pro is 2.7.5. I've made sure to download the appropriate versions of these libraries but it always fails with a "DLL module doesn't exist" type error.
Using a PE viewer I was able to see that other libraries like TKinter were using imports corepython27.dll instead of python27.dll like pillow was.
Also pillow for 2.7 was using msvcr90.dll but the custom version of the tkinter library included with PSP was compiled with msvcr110.dll. Do you think this will be an issue? Do I need to compile pillow with the appropriate version of msvcr DLL? Or is matching versions (2.7) and making sure it uses the correct python.dll (corepython27.dll) the only important thing?
You can create a symbolic link named corepython27.dll showing to the installed python27.dll. You can do this in your console via the command
MKLINK <path_to_corepython.dll> <path_to_python27.dll>
how to convert a gif image to webp in python, keeping it's animation.
from PIL import Image
im = Image.open('test.gif')
im.save('test.webp', 'webp', save_all=True)
get KeyError, is there any python solution?
I just skimmed through the documentation for PIL, which says clearly that webp format is supported. It however comes with a condition. The page states Only supported if the system webp library was built with webpmux support.
In order to continue, you will have to install the latest libwebp library for your corresponding OS. It is recommended to work with it provided you have Debian/Ubuntu OS. There are plenty of resources available on the net to help you.
You may have to reinstall PIL as well
Here is a related thread I came across GITHUB thread
I'm having trouble in finding PIL source code.
The main page of the library http://www.pythonware.com/products/pil/ does not have any link to git repositories.
Is Pillow (https://github.com/python-pillow/Pillow) repository correct project?
PIL was never ported to Python 3, so Pillow forked the project and took it over. Pillow has since been back-ported to Python 2, but if you are working with Python 3, you must use Pillow. They are essentially the same.
If you want the source code of PIL, just download it and look within the files yourself. If you want the documentation for PIL, this is a good reference.
No. I think it is difference project.
https://pillow.readthedocs.io/en/latest/installation.html
When you want to install pillow, you must uninstall PIL