Access OpenCV documentation in spyder - python

I have Python 2.7.9 and OpenCV 3.1.0 installed on a Windows System. I'm using Spyder 2.3.2 and would love to access documentation for OpenCV in the IDE, however using Ctrl+I on cv2 functions/objects only shows No documentation available.
According to this question, OpenCV documentation should be available since Spyder 2.3.1.
Do I need to install additional modules, copy some files or update packages? If I need to upgrade Spyder, how do I do that? (it seems to be part of my pythonxy installation and the python setup on windows often seems so fragile that I'm hesitant to mess around with it)

Support for Jedi in Spyder was added in Spyder 2.3.3, released more than two years ago. Jedi is the library used to get completions and documentation from compiled modules like OpenCV.
The latest Spyder version is 3.1.0, which has better integration with Jedi, so I recommend you to update to that version instead.
However, I don't know how to do it using PythonXY, sorry. You should use the Anaconda distribution instead, which is more up to date than PythonXY.

Related

Which version of python extension support python3.6 in vscode?

I'm shifting from pycharm to vscode for python development and want to check if most of functionality from pycharm such as debugging, gitlab integration, etc... Are possible in VScode.
I've learned that you could install python extension so I did install python v.2022.20.1 extension. However this debugging functionality does not work when I use python 3.6(it says in python extension that it supports python 3.7 and above). I want to find a version that support python 3.6, how can I find it?
I can click drop down beside uninstall block and install another version however there are lots of versions and it is cumbersome to click each one to check...
You can use 2022.08.* or previous versions, later versions no longer support python3.6.

Installing Python 3.11

I want to try out Python 3.11 to find out how much faster this version is than what I'm currently using (3.7.3). I am using Anaconda and Spyder, but Anaconda does not yet support Python 3.11 and additionally I regularly have problems with updating in Anaconda.
Importantly, I want to maintain my Anaconda and Spyder environments as it is and use Python 3.11 independently from this. Therefore, I was wondering if simply downloading Python 3.11 from their website will mess up my environment, as then there will be two versions of Python insalled on my PC. Also I would like to know if I have to use a different IDE for this (or even without IDE).
Even though my question might be a bit vague, thanks in advance.
Try to create new env 3.10 using Anaconda, if Anaconda still doesn't have 3.11. The difference with 3.11 would be (I'm not guaranty, just a "rumors") ~+15%, depends...
You can build and install your version from source :
build-python-from-source
This way you won't break anything and can to delete Python3.11 after experiments.
You can google the benchmark tests for overage performance comparison between <your.version> and <any.over.version> for very common understanding.

Is there any documentation about spyder reports?

I just found out about spyder-reports which can both generate the python code and the HTML output from the .mdw file. I installed it with pip, but then I didn't found any way to work with it. I am using spyder 4.1.3 with python 3.6.4, and nothing changed in the interface, opening a .mdw file doesn't seem to propose anything.. How does this plugin work?
Is there any documentation, examples, I could use to figure out how it works?
Unfortunately, no. According to their GitHub issues:
Sorry, this plugin is unmaintained now and it's not compatible with the latest release of Pweave. We'll come back to it after we release Spyder 4.
and
This plugin is unmaintained and not compatible with the latest release of Pweave. To help update it or see the status of that work, visit this link.
Your best bet at this time is to uninstall since the installation downgrades some packages:
pip uninstall spyder-reports
or
conda uninstall spyder-reports
Sources:
https://github.com/spyder-ide/spyder-reports/issues/76
https://github.com/nathancarter/spyder-reports/commit/5fcddd1503e17b5db8df6f0dbe7444f1698824a6

python vtk 8.2.0 seems to have broken attributes

I am working with a group of people using Ubuntu 16.04 with Python 3.7.3 running Anaconda 2019.03.
For a new project I was trying to use VTK and the version installed was 8.2.0. Running the example from here:
https://lorensen.github.io/VTKExamples/site/Python/IO/ReadSTL/
produces an error "module 'vtk' has no attribute 'vtkSTLReader'".
In further investigation the vtk module only has 9 functions and attributes missing all the ones I am used to.
I moved to another machine where I was easily able to run the example. That machines was ubuntu 20.04 with Anaconda installed with python 3.65 and VTK 8.1.1. I updated anaconda with
conda update conda
conda update --all
This resulted in vtk getting updated to VTK 8.2.0 however now if I simply run a simple python code
import vtk
vtk.
The same thing happened as the work computer. The auto complete after typing period no longer gives a list of all the functions and attributes. And trying to run old code that worked gives errors that the functions and attributes are not available in vtk. I uninstalled vtk from conda and installedthe latest VTK version 9.0.1 using pip and the error is the same. Are there dependencies that don't get updated by conda when you update vtk?
Other things that I tested still work so it just seems like VTK broke. I looked through the API changes between vtk8.1.1 and 8.2.0 and although there are a few it doesn't change some of the ones that are missing like vtkRenderer() or vtkSTLReader().
I was able to go back to vtk8.1.1 and verify it works but I would really like to use vtk 8.2 or greater because there are a group of people using python 3.7 and it would be impractical to have them all move back to Python 3.65 for this.
I am basing the need for VTK >8.2 based on a post I read where python3.7 needs vtk >8.2.
Based on this article I also tried installing python-vtk7 but the package was not found for ubuntu 16.04.
Setting up VTK, with python3.8 and Ubuntu 20.04
I assume I have a mismatch with something simple but just not sure what. I would appreciate if anyone has any insight into if I need to update something else in addition to the conda update.
Adding a little more detail:
I tried pip install python-vtk as well. This installs python-vtk 0.1.0 and replaces vtk with version 8.1.2 with the same error messages. Moving back to python 3.65 and vtk 8.1.1 fixes the problem but I haven't been able to get any version to work with Python 3.7.
Update:
I asked for information through VTK as well.
https://discourse.vtk.org/t/installing-vtk-8-2-for-python-3-7-3-no-attributes-available/3821/4
I add a debug command in the vtk.py file. If I call the import vtk from a editor in spyder the debug does not get printed, but if I call the import vtk from the console in spyder it does. I have no idea why those two would be different.
Thanks
The issue ended up being my openGL support. I had three machines. One was running VMWARE which showed the issue. One was running VNC which showed the issue. And one was running ubuntu natively (using the GPU HW ) which worked fine.
I was running with VMWARE and that worked OK with python 2.x and earlier versions of VTK but when I moved to Python 3x and later versions of VTK it broke because it didn't support the right version of OpenGL. It looks like there are couple different ways to fix it, but in my case the one I used was to use a SW implementation of OpenGL to guarantee support. This was the fastest solution. The other solution would be with a virtual GL driver which leverages the HW and is likely faster and I will likely look at in the future.
For the SW implementation of OpenGL:
sudo apt install llvm-dev # make sure SW driver that supports OPENGL3.2
export LIBGL_ALWAYS_SOFTWARE=1 # Ensures vtk uses sw opengl driver: this needs to be called from each new terminal or alternatively make persistent in bashrc

Installing Numpy developmental over anaconda

I'm pondering switching over to Anaconda from my vanilla Python in OSX. I know Anaconda brings its own NumPy. I was wondering if it was possible to make the GitHub version of NumPy the default version, or if Anaconda only works with its own version.
Anaconda installs python just like it already is on your system, only to a different location. It allows you to choose what packages you want to install. If you want to replace one you can go into the site-packages folder (Anaconda/lib/site-packages) and do so. In my experience, Anaconda was well worth the switch.

Categories

Resources