giorgifafa / editra

Automatically exported from code.google.com/p/editra
0 stars 0 forks source link

Python Code Completion Error When Using OpenCV #796

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
When I'm using Editra to write some Python code involved the OpenCV module, the 
code completion behaves strangely. After I import the cv2 module, it sometimes 
works well, and show a word completion list correctly. But it more often 
doesn't work. And the log show:

[12:16:51][pycomp][info] get_completions('cv.','')
[12:16:51][pycomp][err] get_completions: name 'cv' is not defined 
[stmt='cv']

See the attached picture.

What is the expected output? What do you see instead?

IMPORTANT!!! Please answer these questions for any and ALL bug reports

What version of the product are you using? On what operating system?
Version 0.7.20

What method of install was your version installed with (Binary/Source)?
Binary

If from source: What version of python and wxPython are you using?

Please provide any additional information below.
My System is Win7 x64 HomeBasic

Original issue reported on code.google.com by NoAnyL...@gmail.com on 22 Mar 2013 at 4:19

Attachments:

GoogleCodeExporter commented 9 years ago
The Binary installs of Editra use their own copy of Python built into the 
binary with only the libraries that Editra itself uses. So the auto-completion 
does not have access to any modules that you have installed on your system 
Python.

If you are developing Python code I highly suggest installing Editra as a 
python module instead of the binary install. Because then it will be running on 
your system python and have access to all the 3rd party modules installed on 
that python.

This is a recognized limitation in the current autocompletion support in 
Editra. There are already plans for re-designing it to be able to use your 
system python in binary versions the future so I am closing this as Invalid 
based on the above advice.

Original comment by CodyPrec...@gmail.com on 22 Mar 2013 at 4:36

GoogleCodeExporter commented 9 years ago
I'm now using the source version of Editra, and installed it as a python 
module. But it still behave strangely. After I import cv2 module(import cv2.cv 
as cv), and input cv.,it firstly work well and show the word completion 
correctly, but it will soon become unavaliable, and shows error like the 
attached picture above, if I delete the dot sign, and reinput the dot sign. Or 
if I choose one item in the word completion list and hit Enter. 

I'm using Pythojn 2.7.1

Original comment by NoAnyL...@gmail.com on 23 Mar 2013 at 1:18

GoogleCodeExporter commented 9 years ago
Will investigate further

Original comment by CodyPrec...@gmail.com on 23 Mar 2013 at 1:24

GoogleCodeExporter commented 9 years ago
I am having some trouble finding this opencv module there are several different 
ones showing up.

Can you please provide a link to a download location and the names of any tools 
that are needed to install this so that I can try to test?

Original comment by CodyPrec...@gmail.com on 23 Mar 2013 at 1:40

GoogleCodeExporter commented 9 years ago
The OpenCV module for Python is just a file named cv2.pyd,you can find it in 
the OpenCV install path under \opencv\build\python\2.7, and just copy it to the 
Lib folder or the site-packages folder of Python.

You can download OpenCV install package(For Windows, its about 259MB) 
here:http://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.4.4/OpenCV
-2.4.4.exe/download

Or, you can just use the cv2.pyd file I attached below, this one is for Python 
2.7.

Original comment by NoAnyL...@gmail.com on 23 Mar 2013 at 3:06

Attachments:

GoogleCodeExporter commented 9 years ago
I am not able to reproduce the issue so far:

1) Running python2.7
2) Running source version of Editra with python2.7 (C:\Python27\python.exe 
editra)
3) import cv2 as cv
4) cv.   (yields popup list of possible completions)

I did run into the issue you had briefly when I didn't have numpy installed as 
it caused the import evaluation of cv2 to fail. The log output clearly showed 
this as the problem a few lines above the error about 'cv'.

Do you have a sample file that can be used to reproduce this issue?

Are there any other error statements in the log window when you try to type 
completions?

Original comment by CodyPrec...@gmail.com on 24 Mar 2013 at 3:54

GoogleCodeExporter commented 9 years ago
Of course I have installed numpy. 

A log showed like this:
[12:48:58][ed_main][info] Loading Generator plugins
[12:48:58][ed_main][info] CMD Open File: 
D:\WorkSpace\Python学习\opencv\Test.py
[12:48:58][ed_txt][info] CheckBom called
[12:48:58][ed_txt][info] DetectEncoding - Check magic comment
[12:48:58][ed_txt][info] CheckMagicComment: ['', '']
[12:48:58][ed_txt][info] MagicComment is None
[12:48:58][ed_txt][info] Doing brute force encoding check
[12:48:58][ed_txt][info] DetectEncoding - Set Encoding to cp936
[12:48:58][ed_txt][info] Resetting buffer
[12:48:58][ed_txt][info] Read - Start reading
[12:48:58][ed_txt][info] Read - End reading
[12:48:58][ed_txt][info] Attempting to decode with: cp936
[12:48:58][ed_txt][info] Decoded D:\WorkSpace\Python学习\opencv\Test.py with 
cp936
[12:48:58][ed_txt][info] Resetting buffer
[12:48:58][ed_stc][info] Lexer change notification for context -206
[12:48:58][launch][info] Lexer changed handler - context -206
[12:48:58][Launch][info] Found commands ['pylint', 'pylinterr', 'python']
[12:48:58][Launch][info] Found commands ['pylint', 'pylinterr', 'python']
[12:48:58][ed_pages][evt] Opened Page: Test.py
[12:48:58][main][info] Starting MainLoop...
[12:48:59][codebrowser][info] Syncing tree for position 0
[12:48:59][codebrowser][info] Syncing tree for position 0
[12:49:00][codebrowser][info] Syncing tree for position 0
[12:49:02][pycomp][info] Successfully executed source code
[12:49:02][pycomp][info] Completion eval time: 0.017000
[12:49:02][pycomp][info] get_completions('cv2.','')
[12:49:02][pycomp][err] get_completions: name 'cv2' is not defined [stmt='cv2']
[12:49:02][codebrowser][info] Syncing tree for position 0
[12:49:03][codebrowser][info] Syncing tree for position 0
[12:49:04][codebrowser][info] Syncing tree for position 0
[12:49:05][codebrowser][info] Syncing tree for position 1
[12:49:06][pycomp][info] Successfully executed source code
[12:49:06][pycomp][info] Successfully executed: import cv2.cv as cv
[12:49:06][pycomp][info] Completion eval time: 0.177000
[12:49:06][pycomp][info] get_completions('cv.','')
[12:49:06][pycomp][info] completing: stmt:cv
[12:49:06][codebrowser][info] Syncing tree for position 1
[12:49:11][codebrowser][info] Syncing tree for position 1
[12:49:11][codebrowser][info] Syncing tree for position 1
[12:49:13][codebrowser][info] Syncing tree for position 1
[12:49:14][pycomp][err] Pyparser.parse: <class 'tokenize.TokenError'>, ('EOF in 
multi-line statement', (3, 0))
[12:49:14][pycomp][info] Successfully executed source code
[12:49:14][pycomp][err] local exec No module named cv [import cv2.cv as cv]
[12:49:14][pycomp][info] Completion eval time: 0.005000
[12:49:14][pycomp][info] get_completions('cv.NamedWindow((','')
[12:49:14][pycomp][err] get_completions: name 'cv' is not defined 
[stmt='cv.NamedWindow((']
[12:49:14][codebrowser][info] Syncing tree for position 1

I just use the simplest import cv2.cv as cv, and hit cv.

I think a video can show the situation better. I have recorded a video about 
the two situation that will cause error in my computer. I use wink to record it 
as a swf(flash) file and attatched it below. You'd better use 1.htm to play it 
in Web Browser. I hope it would be helpful.

Original comment by NoAnyL...@gmail.com on 24 Mar 2013 at 5:06

Attachments:

GoogleCodeExporter commented 9 years ago
Thank you for the extra information, I am clearly seeing the issue now.

It appears to be a defect in the parser. In testing so far if I do the 
following it can work around the issue until a fix is found.

Change import to: 'from cv2 import cv'

Will update when real fix is implemented.

Original comment by CodyPrec...@gmail.com on 24 Mar 2013 at 7:27