JIA Pei | 24 Jan 13:41 2010
Picon

How to import opencv python into Eric IDE?


Hi, all:

Sorry that I'm starting using Python these days and would like to know how to import opencv into my python IDE Eric ?

I created a new Python project from Eric4 and just created one file for this project, say:
FirstTest.py ,

"
import cv
cv.SaveImage("foo.png", cv.LoadImage("foo.jpg"))
"

1) Whenever I ran my script by "python FirstTest" from within Eric IDE, I obtained:
p, li { white-space: pre-wrap; }

The debugged program raised the exception unhandled ImportError
"No module named cv"
File: /home/jiapei/MyPrograms/Python/Eric/FirstTest/FirstTest.py, Line: 1

Break here?



2) Whenever I ran my script by "python FirstTest" from within bash, I obtained:

Traceback (most recent call last):
  File "FirstTest.py", line 1, in <module>
    import cv
ImportError: No module named cv



So, It looks like Python is not able to find opencv's python package yet.
Is there anything specific I need to pay attention to when installing opencv with Python support?
For example, do I have to put some files in some particular folders like "/usr/lib/python***" ?


Looking forward to your reply.



Best Regards
JIA  Pei




--
Welcome to Vision Open
http://www.visionopen.com
------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
opencvlibrary-users mailing list
opencvlibrary-users@...
https://lists.sourceforge.net/lists/listinfo/opencvlibrary-users
Vadim Pisarevsky | 25 Jan 18:47 2010
Picon

Re: How to import opencv python into Eric IDE?

Hi JIA,


cv.so (that can be found in <CMakeGeneratedBuildDir>/lib) should be either copied somewhere to /usr/lib/python2.<...>/site-packages or to the directory where is your script.

Regards,
Vadim

On Sun, Jan 24, 2010 at 3:41 PM, JIA Pei <jp4work-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:

Hi, all:

Sorry that I'm starting using Python these days and would like to know how to import opencv into my python IDE Eric ?

I created a new Python project from Eric4 and just created one file for this project, say:
FirstTest.py ,

"
import cv
cv.SaveImage("foo.png", cv.LoadImage("foo.jpg"))
"

1) Whenever I ran my script by "python FirstTest" from within Eric IDE, I obtained:

The debugged program raised the exception unhandled ImportError
"No module named cv"
File: /home/jiapei/MyPrograms/Python/Eric/FirstTest/FirstTest.py, Line: 1

Break here?



2) Whenever I ran my script by "python FirstTest" from within bash, I obtained:

Traceback (most recent call last):
  File "FirstTest.py", line 1, in <module>
    import cv
ImportError: No module named cv



So, It looks like Python is not able to find opencv's python package yet.
Is there anything specific I need to pay attention to when installing opencv with Python support?
For example, do I have to put some files in some particular folders like "/usr/lib/python***" ?


Looking forward to your reply.



Best Regards
JIA  Pei




--
Welcome to Vision Open
http://www.visionopen.com

------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
opencvlibrary-users mailing list
opencvlibrary-users@...
https://lists.sourceforge.net/lists/listinfo/opencvlibrary-users
JIA Pei | 27 Jan 02:47 2010
Picon

Re: How to import opencv python into Eric IDE?


Hi, Thank you very much VP.

Sorry that since I just started using Python these days, for fun.

I followed your suggestion and copy cv.so to the directory that my script is in, and program runs !!! Thanks !!!
However, problems continue:

1) I'm now trying opencv-python samples.

Unlike the first example I showed you:
"import cv
cv.SaveImage("foo.png", cv.LoadImage("foo.jpg"))"

Example in /usr/local/share/opencv/samples/python always import opencv in a way like
a) from opencv import cv
b) from opencv.cv import *

Then, I'll obtain the error message as:

p, li { white-space: pre-wrap; }

The debugged program raised the exception unhandled ImportError
"No module named opencv"
File: /home/jiapei/MyPrograms/Python/Eric/opencv/cam-histo.py, Line: 6

Break here?

The error message is quite similar to the former one but clearly, there is nothing named "opencv.so"


2) Since I've installed multiple version of python. (Some times, it's just because other required packages depend on old python.)
So, in my /usr/lib, I have
jiapei <at> jiapei-laptop:/usr/lib$ cd python
python/         python2.5/      python3.0/      python-support/
python2.4/      python2.6/      python3.1/      python-tz/


And, there is only one folder named "site-packages" under python2.5
jiapei <at> jiapei-laptop:/usr/lib/python2.5/site-packages$

However, this seems not compatible with opencv compilation since I'm pretty sure I built current version of opencv using python2.6 .

Therefore, are you sure that cv.so must be copied to /usr/lib/python2.5/site-packages ??




Yes, it could be better if I can copy cv.so to a particular folder just once, rather than copy it around here and there under the same folder as my projects.


Can anybody give me a clue?

Best Regards
JIA Pei





On Mon, Jan 25, 2010 at 5:47 PM, Vadim Pisarevsky <vadim.pisarevsky-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
Hi JIA,

cv.so (that can be found in <CMakeGeneratedBuildDir>/lib) should be either copied somewhere to /usr/lib/python2.<...>/site-packages or to the directory where is your script.

Regards,
Vadim


On Sun, Jan 24, 2010 at 3:41 PM, JIA Pei <jp4work-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:

Hi, all:

Sorry that I'm starting using Python these days and would like to know how to import opencv into my python IDE Eric ?

I created a new Python project from Eric4 and just created one file for this project, say:
FirstTest.py ,

"
import cv
cv.SaveImage("foo.png", cv.LoadImage("foo.jpg"))
"

1) Whenever I ran my script by "python FirstTest" from within Eric IDE, I obtained:

The debugged program raised the exception unhandled ImportError
"No module named cv"
File: /home/jiapei/MyPrograms/Python/Eric/FirstTest/FirstTest.py, Line: 1

Break here?



2) Whenever I ran my script by "python FirstTest" from within bash, I obtained:

Traceback (most recent call last):
  File "FirstTest.py", line 1, in <module>
    import cv
ImportError: No module named cv



So, It looks like Python is not able to find opencv's python package yet.
Is there anything specific I need to pay attention to when installing opencv with Python support?
For example, do I have to put some files in some particular folders like "/usr/lib/python***" ?


Looking forward to your reply.



Best Regards
JIA  Pei




--
Welcome to Vision Open
http://www.visionopen.com




--
Welcome to Vision Open
http://www.visionopen.com
------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
opencvlibrary-users mailing list
opencvlibrary-users@...
https://lists.sourceforge.net/lists/listinfo/opencvlibrary-users
CpILL | 29 Jan 01:14 2010

Re: How to import opencv python into Eric IDE?

Hey JIA,

1) I found that the "from opencv" is for the old SWIG pyhton bindings. Someone should go though and convert these to "import cv". I think all the stuff that was in the SWIG bindings is in the cv.so file now. Planning on having a go at this myself when I get some time. Documentation is low or dated in the Python bindings department it seems :-/

2) I'm pretty sure you'll have to compile cv.so for each version of Python your using as its dynamically linked to the various Python lib's (of a specific Python version). In fact I can confirm if you try to use cv.so with a different version of Python you'll get an error when you do the "import cv". I documented my woes with this here: http://www.tsd.net.au/blog/opencv-python-bindings-macports

hope that helps. I'm keen to explore the Python side of OpenCV too and open to collaboration.

word

alex

On 27/01/10 2:47 AM, JIA Pei wrote:

Hi, Thank you very much VP.

Sorry that since I just started using Python these days, for fun.

I followed your suggestion and copy cv.so to the directory that my script is in, and program runs !!! Thanks !!!
However, problems continue:

1) I'm now trying opencv-python samples.

Unlike the first example I showed you:
"import cv
cv.SaveImage("foo.png", cv.LoadImage("foo.jpg"))"

Example in /usr/local/share/opencv/samples/python always import opencv in a way like
a) from opencv import cv
b) from opencv.cv import *

Then, I'll obtain the error message as:

p, li { white-space: pre-wrap; }

The debugged program raised the exception unhandled ImportError
"No module named opencv"

File: /home/jiapei/MyPrograms/Python/Eric/opencv/cam-histo.py, Line: 6

Break here?

The error message is quite similar to the former one but clearly, there is nothing named "opencv.so"


2) Since I've installed multiple version of python. (Some times, it's just because other required packages depend on old python.)
So, in my /usr/lib, I have
jiapei <at> jiapei-laptop:/usr/lib$ cd python
python/         python2.5/      python3.0/      python-support/
python2.4/      python2.6/      python3.1/      python-tz/


And, there is only one folder named "site-packages" under python2.5
jiapei <at> jiapei-laptop:/usr/lib/python2.5/site-packages$

However, this seems not compatible with opencv compilation since I'm pretty sure I built current version of opencv using python2.6 .

Therefore, are you sure that cv.so must be copied to /usr/lib/python2.5/site-packages ??




Yes, it could be better if I can copy cv.so to a particular folder just once, rather than copy it around here and there under the same folder as my projects.


Can anybody give me a clue?

Best Regards
JIA Pei

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com

Gmane