New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

install pycrypto #42

Closed
bastman opened this Issue Jul 27, 2011 · 11 comments

Comments

Projects
None yet
3 participants
@bastman

bastman commented Jul 27, 2011

Hi Fabio,

I'm new to python and have some trouble get your thumbor running on my ubuntu regarding the Crypto.Cipher lib

I run setup.py, installed pycrypto and started app.py , but got an exception:

File "app.py", line 21, in
from thumbor.handlers.crypto import CryptoHandler
File "/usr/local/lib/python2.6/dist-packages/thumbor-0.8.3-py2.6.egg/thumbor/handlers/crypto.py", line 15, in
from thumbor.crypto import Crypto
File "/usr/local/lib/python2.6/dist-packages/thumbor-0.8.3-py2.6.egg/thumbor/crypto.py", line 14, in
from Crypto.Cipher import AES
ImportError: cannot import name AES

I even placed the Crypto source in thumbor/Cryptor and run a test app:

from Crypto.Cipher import DES3
from Crypto.Cipher import AES

In that case I did not get an error.

Fabio, do you know what I'm doing wrong?

cheers
seb

@heynemann

This comment has been minimized.

Show comment
Hide comment
@heynemann

heynemann Jul 27, 2011

Member

Without copying Crypto source, try the following:

$ python
from Crypto.Cipher import AES

What happens?

Cheers,
Bernardo Heynemann

Member

heynemann commented Jul 27, 2011

Without copying Crypto source, try the following:

$ python
from Crypto.Cipher import AES

What happens?

Cheers,
Bernardo Heynemann

@fabiomcosta

This comment has been minimized.

Show comment
Hide comment
@fabiomcosta

fabiomcosta Jul 27, 2011

Member

What's your pycrypto version? We are using 2.3 here.

Member

fabiomcosta commented Jul 27, 2011

What's your pycrypto version? We are using 2.3 here.

@bastman

This comment has been minimized.

Show comment
Hide comment
@bastman

bastman Jul 28, 2011

Hi Bernado,

I opened a shell and typed:

$ python
from Crypto.Cipher import AES

Everything was fine, it did not throw an exception.

Do you have an idea, why my installed thumbor egg can't import the Crypto.Cipher.AES ?

Thx.

seb

bastman commented Jul 28, 2011

Hi Bernado,

I opened a shell and typed:

$ python
from Crypto.Cipher import AES

Everything was fine, it did not throw an exception.

Do you have an idea, why my installed thumbor egg can't import the Crypto.Cipher.AES ?

Thx.

seb

@bastman

This comment has been minimized.

Show comment
Hide comment
@bastman

bastman Jul 28, 2011

Hi Fabio,

I opened a shell and:

import Crypto
Crypto.version
'2.0.1'

So I guess, I have the wrong version.

bastman commented Jul 28, 2011

Hi Fabio,

I opened a shell and:

import Crypto
Crypto.version
'2.0.1'

So I guess, I have the wrong version.

@bastman

This comment has been minimized.

Show comment
Hide comment
@bastman

bastman Jul 28, 2011

Hi Fabio, Hi Bernado,

I just tried a different approach (since I realized that pycrypto 2.3 requires python 2.7).
I successfully install pycrypto 2.3, but now I have a new error:

ImportError: No module named cv

Basically I installed python 2.7.2 in a virtualenv called "fabula" (I just followed that tutorial: http://technomilk.wordpress.com/tag/pythonbrew/)

Than ...

workon fabula
(fabula)seb@sebVM:~$ python -V
Python 2.7.2

pip install pycrypto

(fabula)seb@sebVM:$ python -c "import Crypto; print Crypto.version"
2.3
(fabula)seb@sebVM:
$

pip install thumbor
Successfully installed thumbor tornado redis pycurl pillow

(fabula)seb@sebVM:~$ thumbor
Traceback (most recent call last):
File "/home/seb/.virtualenvs/fabula/bin/thumbor", line 8, in
load_entry_point('thumbor==0.8.4', 'console_scripts', 'thumbor')()
File "/home/seb/.virtualenvs/fabula/lib/python2.7/site-packages/thumbor/server.py", line 82, in main
run_app(ip, port, conf, log_level, options.app)
File "/home/seb/.virtualenvs/fabula/lib/python2.7/site-packages/thumbor/server.py", line 95, in run_app
application = ThumborServiceApp(conf)
File "/home/seb/.virtualenvs/fabula/lib/python2.7/site-packages/thumbor/app.py", line 37, in init
self.detectors = [real_import(detector_name).Detector for detector_name in conf.DETECTORS]
File "/home/seb/.virtualenvs/fabula/lib/python2.7/site-packages/thumbor/utils.py", line 15, in real_import
return reduce(getattr, name.split('.')[1:], import(name))
File "/home/seb/.virtualenvs/fabula/lib/python2.7/site-packages/thumbor/detectors/init.py", line 13, in
import cv
ImportError: No module named cv

Do you guys have an idea, what I'm doing wrong?

thx.

seb

bastman commented Jul 28, 2011

Hi Fabio, Hi Bernado,

I just tried a different approach (since I realized that pycrypto 2.3 requires python 2.7).
I successfully install pycrypto 2.3, but now I have a new error:

ImportError: No module named cv

Basically I installed python 2.7.2 in a virtualenv called "fabula" (I just followed that tutorial: http://technomilk.wordpress.com/tag/pythonbrew/)

Than ...

workon fabula
(fabula)seb@sebVM:~$ python -V
Python 2.7.2

pip install pycrypto

(fabula)seb@sebVM:$ python -c "import Crypto; print Crypto.version"
2.3
(fabula)seb@sebVM:
$

pip install thumbor
Successfully installed thumbor tornado redis pycurl pillow

(fabula)seb@sebVM:~$ thumbor
Traceback (most recent call last):
File "/home/seb/.virtualenvs/fabula/bin/thumbor", line 8, in
load_entry_point('thumbor==0.8.4', 'console_scripts', 'thumbor')()
File "/home/seb/.virtualenvs/fabula/lib/python2.7/site-packages/thumbor/server.py", line 82, in main
run_app(ip, port, conf, log_level, options.app)
File "/home/seb/.virtualenvs/fabula/lib/python2.7/site-packages/thumbor/server.py", line 95, in run_app
application = ThumborServiceApp(conf)
File "/home/seb/.virtualenvs/fabula/lib/python2.7/site-packages/thumbor/app.py", line 37, in init
self.detectors = [real_import(detector_name).Detector for detector_name in conf.DETECTORS]
File "/home/seb/.virtualenvs/fabula/lib/python2.7/site-packages/thumbor/utils.py", line 15, in real_import
return reduce(getattr, name.split('.')[1:], import(name))
File "/home/seb/.virtualenvs/fabula/lib/python2.7/site-packages/thumbor/detectors/init.py", line 13, in
import cv
ImportError: No module named cv

Do you guys have an idea, what I'm doing wrong?

thx.

seb

@heynemann

This comment has been minimized.

Show comment
Hide comment
@heynemann

heynemann Jul 28, 2011

Member

Sure. cv is OpenCV, the library we use to do facial recognition.

You can disable facial recognition commenting all the detectors.

For instructions on installing on Mac OSX check the wiki at
https://github.com/globocom/thumbor/wiki/Requirements

After you install OpenCV, there will be a file called cv.so somewhere
(probably default python lib path). Just link it to your virtual env
site-packages folder.

Cheers,
Bernardo Heynemann

On Thu, Jul 28, 2011 at 12:14 PM, bastman <
reply@reply.github.com>wrote:

Hi Fabio, Hi Bernado,

I just tried a different approach (since I realized that pycrypto 2.3
requires python 2.7).
I successfully install pycrypto 2.3, but now I have a new error:

ImportError: No module named cv

Basically I installed python 2.7.2 in a virtualenv called "fabula" (I just
followed that tutorial: http://technomilk.wordpress.com/tag/pythonbrew/)

Than ...

workon fabula
(fabula)seb@sebVM:~$ python -V
Python 2.7.2

pip install pycrypto

(fabula)seb@sebVM:$ python -c "import Crypto; print Crypto.version"
2.3
(fabula)seb@sebVM:
$

pip install thumbor
Successfully installed thumbor tornado redis pycurl pillow

(fabula)seb@sebVM:~$ thumbor
Traceback (most recent call last):
File "/home/seb/.virtualenvs/fabula/bin/thumbor", line 8, in
load_entry_point('thumbor==0.8.4', 'console_scripts', 'thumbor')()
File
"/home/seb/.virtualenvs/fabula/lib/python2.7/site-packages/thumbor/server.py",
line 82, in main
run_app(ip, port, conf, log_level, options.app)
File
"/home/seb/.virtualenvs/fabula/lib/python2.7/site-packages/thumbor/server.py",
line 95, in run_app
application = ThumborServiceApp(conf)
File
"/home/seb/.virtualenvs/fabula/lib/python2.7/site-packages/thumbor/app.py",
line 37, in init
self.detectors = [real_import(detector_name).Detector for detector_name
in conf.DETECTORS]
File
"/home/seb/.virtualenvs/fabula/lib/python2.7/site-packages/thumbor/utils.py",
line 15, in real_import
return reduce(getattr, name.split('.')[1:], import(name))
File
"/home/seb/.virtualenvs/fabula/lib/python2.7/site-packages/thumbor/detectors/init.py",
line 13, in
import cv
ImportError: No module named cv

Do you guys have an idea, what I'm doing wrong?

thx.

seb

Reply to this email directly or view it on GitHub:
#42 (comment)

Member

heynemann commented Jul 28, 2011

Sure. cv is OpenCV, the library we use to do facial recognition.

You can disable facial recognition commenting all the detectors.

For instructions on installing on Mac OSX check the wiki at
https://github.com/globocom/thumbor/wiki/Requirements

After you install OpenCV, there will be a file called cv.so somewhere
(probably default python lib path). Just link it to your virtual env
site-packages folder.

Cheers,
Bernardo Heynemann

On Thu, Jul 28, 2011 at 12:14 PM, bastman <
reply@reply.github.com>wrote:

Hi Fabio, Hi Bernado,

I just tried a different approach (since I realized that pycrypto 2.3
requires python 2.7).
I successfully install pycrypto 2.3, but now I have a new error:

ImportError: No module named cv

Basically I installed python 2.7.2 in a virtualenv called "fabula" (I just
followed that tutorial: http://technomilk.wordpress.com/tag/pythonbrew/)

Than ...

workon fabula
(fabula)seb@sebVM:~$ python -V
Python 2.7.2

pip install pycrypto

(fabula)seb@sebVM:$ python -c "import Crypto; print Crypto.version"
2.3
(fabula)seb@sebVM:
$

pip install thumbor
Successfully installed thumbor tornado redis pycurl pillow

(fabula)seb@sebVM:~$ thumbor
Traceback (most recent call last):
File "/home/seb/.virtualenvs/fabula/bin/thumbor", line 8, in
load_entry_point('thumbor==0.8.4', 'console_scripts', 'thumbor')()
File
"/home/seb/.virtualenvs/fabula/lib/python2.7/site-packages/thumbor/server.py",
line 82, in main
run_app(ip, port, conf, log_level, options.app)
File
"/home/seb/.virtualenvs/fabula/lib/python2.7/site-packages/thumbor/server.py",
line 95, in run_app
application = ThumborServiceApp(conf)
File
"/home/seb/.virtualenvs/fabula/lib/python2.7/site-packages/thumbor/app.py",
line 37, in init
self.detectors = [real_import(detector_name).Detector for detector_name
in conf.DETECTORS]
File
"/home/seb/.virtualenvs/fabula/lib/python2.7/site-packages/thumbor/utils.py",
line 15, in real_import
return reduce(getattr, name.split('.')[1:], import(name))
File
"/home/seb/.virtualenvs/fabula/lib/python2.7/site-packages/thumbor/detectors/init.py",
line 13, in
import cv
ImportError: No module named cv

Do you guys have an idea, what I'm doing wrong?

thx.

seb

Reply to this email directly or view it on GitHub:
#42 (comment)

@fabiomcosta

This comment has been minimized.

Show comment
Hide comment
@fabiomcosta

fabiomcosta Jul 28, 2011

Member

Just FYI, we use pycrypto here with python 2.6.
To install opencv on a mac for python 2.6, you can use homebrew (https://github.com/mxcl/homebrew) brew install opencv && export PYTHONPATH="#{HOMEBREW_PREFIX}/lib/python2.6/site-packages/:$PYTHONPATH"

Member

fabiomcosta commented Jul 28, 2011

Just FYI, we use pycrypto here with python 2.6.
To install opencv on a mac for python 2.6, you can use homebrew (https://github.com/mxcl/homebrew) brew install opencv && export PYTHONPATH="#{HOMEBREW_PREFIX}/lib/python2.6/site-packages/:$PYTHONPATH"

@bastman

This comment has been minimized.

Show comment
Hide comment
@bastman

bastman Jul 29, 2011

Hi Fabio, Hi Bernado,

thx. for your advices. Finally I compiled opencv on my ubuntu, and launched thumbor without raising exceptions.

Than I tried your example:

http://localhost:8888/300x200/smart/s.glbimg.com/et/bb/f/original/2011/03/24/VN0JiwzmOw0b0lg.jpg

But got http 500 error. The image url is correct and image is available, but thumbor throws errors while processing:

HTTPRequest(protocol='http', host='localhost:8888', method='GET', uri='/300x200/smart/s.glbimg.com/et/bb/f/original/2011/03/24/VN0JiwzmOw0b0lg.jpg', version='HTTP/1.1', remote_ip='127.0.0.1', body='', headers={'Host': 'localhost:8888', 'Accept-Language': 'en-us,en;q=0.5', 'Accept-Encoding': 'gzip,deflate', 'Keep-Alive': '115', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8', 'User-Agent': 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.8) Gecko/20100723 Ubuntu/10.04 (lucid) Firefox/3.6.8', 'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,_;q=0.7', 'Connection': 'keep-alive'})
Traceback (most recent call last):
File "/home/seb/.virtualenvs/fabula267/lib/python2.6/site-packages/tornado/web.py", line 861, in _execute
getattr(self, self.request.method.lower())(_args, *_kwargs)
File "/home/seb/.virtualenvs/fabula267/lib/python2.6/site-packages/tornado/web.py", line 941, in wrapper
return method(self, *args, *kwargs)
File "/home/seb/.virtualenvs/fabula267/lib/python2.6/site-packages/thumbor/handlers/crypto.py", line 30, in get
opt = cr.decrypt(crypto)
File "/home/seb/.virtualenvs/fabula267/lib/python2.6/site-packages/thumbor/crypto.py", line 61, in decrypt
debased = base64.urlsafe_b64decode(encrypted)
File "/usr/lib/python2.6/base64.py", line 112, in urlsafe_b64decode
return b64decode(s, '-
')
File "/usr/lib/python2.6/base64.py", line 76, in b64decode
raise TypeError(msg)
TypeError: Incorrect padding
ERROR:root:500 GET /300x200/smart/s.glbimg.com/et/bb/f/original/2011/03/24/VN0JiwzmOw0b0lg.jpg (127.0.0.1) 6.89ms

Do you guys have an idea?

Thx.

seb

bastman commented Jul 29, 2011

Hi Fabio, Hi Bernado,

thx. for your advices. Finally I compiled opencv on my ubuntu, and launched thumbor without raising exceptions.

Than I tried your example:

http://localhost:8888/300x200/smart/s.glbimg.com/et/bb/f/original/2011/03/24/VN0JiwzmOw0b0lg.jpg

But got http 500 error. The image url is correct and image is available, but thumbor throws errors while processing:

HTTPRequest(protocol='http', host='localhost:8888', method='GET', uri='/300x200/smart/s.glbimg.com/et/bb/f/original/2011/03/24/VN0JiwzmOw0b0lg.jpg', version='HTTP/1.1', remote_ip='127.0.0.1', body='', headers={'Host': 'localhost:8888', 'Accept-Language': 'en-us,en;q=0.5', 'Accept-Encoding': 'gzip,deflate', 'Keep-Alive': '115', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8', 'User-Agent': 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.8) Gecko/20100723 Ubuntu/10.04 (lucid) Firefox/3.6.8', 'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,_;q=0.7', 'Connection': 'keep-alive'})
Traceback (most recent call last):
File "/home/seb/.virtualenvs/fabula267/lib/python2.6/site-packages/tornado/web.py", line 861, in _execute
getattr(self, self.request.method.lower())(_args, *_kwargs)
File "/home/seb/.virtualenvs/fabula267/lib/python2.6/site-packages/tornado/web.py", line 941, in wrapper
return method(self, *args, *kwargs)
File "/home/seb/.virtualenvs/fabula267/lib/python2.6/site-packages/thumbor/handlers/crypto.py", line 30, in get
opt = cr.decrypt(crypto)
File "/home/seb/.virtualenvs/fabula267/lib/python2.6/site-packages/thumbor/crypto.py", line 61, in decrypt
debased = base64.urlsafe_b64decode(encrypted)
File "/usr/lib/python2.6/base64.py", line 112, in urlsafe_b64decode
return b64decode(s, '-
')
File "/usr/lib/python2.6/base64.py", line 76, in b64decode
raise TypeError(msg)
TypeError: Incorrect padding
ERROR:root:500 GET /300x200/smart/s.glbimg.com/et/bb/f/original/2011/03/24/VN0JiwzmOw0b0lg.jpg (127.0.0.1) 6.89ms

Do you guys have an idea?

Thx.

seb

@fabiomcosta

This comment has been minimized.

Show comment
Hide comment
@fabiomcosta

fabiomcosta Jul 29, 2011

Member

Bastman,

try this http://localhost:8888/unsafe/300x200/smart/s.glbimg.com/et/bb/f/original/2011/03/24/VN0JiwzmOw0b0lg.jpg

Thumbor is configured to be used with encripted URLs, but you can use these uncripted URLs for testing purpose.

More on this here:

https://github.com/globocom/thumbor/wiki/Security
https://github.com/globocom/thumbor/wiki/Libraries

Thank you for your feedbacks!

Member

fabiomcosta commented Jul 29, 2011

Bastman,

try this http://localhost:8888/unsafe/300x200/smart/s.glbimg.com/et/bb/f/original/2011/03/24/VN0JiwzmOw0b0lg.jpg

Thumbor is configured to be used with encripted URLs, but you can use these uncripted URLs for testing purpose.

More on this here:

https://github.com/globocom/thumbor/wiki/Security
https://github.com/globocom/thumbor/wiki/Libraries

Thank you for your feedbacks!

@bastman

This comment has been minimized.

Show comment
Hide comment
@bastman

bastman Jul 29, 2011

Hi Fabio, thanks a lot it works!

Excellent job guys!

Bye the way I tested Bernado's thubor-url - and it works!

(fabula267)seb@sebVM:~$ thumbor-url --width=100 --height=100 --smart s.glbimg.com/et/bb/f/original/2011/03/24/VN0JiwzmOw0b0lg.jpg

USING CONFIGURATION FILE AT /home/seb/.virtualenvs/fabula267/lib/python2.6/site-packages/thumbor/thumbor.conf

Encrypted URL: "/4VWiOt2cqnurhbkMI7xnDW6SMeUU0b8JHJeMZLF0X5CVfPS8lxUNUErL7wX9hxeh/s.glbimg.com/et/bb/f/original/2011/03/24/VN0JiwzmOw0b0lg.jpg" (without quotes)
(fabula267)seb@sebVM:~$

... and that is the "safe"-url to that image(w=100,h=100,smart):

http://localhost:8888/4VWiOt2cqnurhbkMI7xnDW6SMeUU0b8JHJeMZLF0X5CVfPS8lxUNUErL7wX9hxeh/s.glbimg.com/et/bb/f/original/2011/03/24/VN0JiwzmOw0b0lg.jpg

By the way is there a php port for thumbor-url available?

thx

seb

bastman commented Jul 29, 2011

Hi Fabio, thanks a lot it works!

Excellent job guys!

Bye the way I tested Bernado's thubor-url - and it works!

(fabula267)seb@sebVM:~$ thumbor-url --width=100 --height=100 --smart s.glbimg.com/et/bb/f/original/2011/03/24/VN0JiwzmOw0b0lg.jpg

USING CONFIGURATION FILE AT /home/seb/.virtualenvs/fabula267/lib/python2.6/site-packages/thumbor/thumbor.conf

Encrypted URL: "/4VWiOt2cqnurhbkMI7xnDW6SMeUU0b8JHJeMZLF0X5CVfPS8lxUNUErL7wX9hxeh/s.glbimg.com/et/bb/f/original/2011/03/24/VN0JiwzmOw0b0lg.jpg" (without quotes)
(fabula267)seb@sebVM:~$

... and that is the "safe"-url to that image(w=100,h=100,smart):

http://localhost:8888/4VWiOt2cqnurhbkMI7xnDW6SMeUU0b8JHJeMZLF0X5CVfPS8lxUNUErL7wX9hxeh/s.glbimg.com/et/bb/f/original/2011/03/24/VN0JiwzmOw0b0lg.jpg

By the way is there a php port for thumbor-url available?

thx

seb

@bastman bastman closed this Jul 29, 2011

@fabiomcosta

This comment has been minimized.

Show comment
Hide comment
@fabiomcosta

fabiomcosta Jul 29, 2011

Member

Cool! :P

No, there isn't a PHP port for thumbor-url, but there are specifications for creating a new port here:

https://github.com/globocom/thumbor/wiki/Libraries

If you do the PHP port we will happily include it on the page.

If you need any feedback/help feel free to contact any of us.

Member

fabiomcosta commented Jul 29, 2011

Cool! :P

No, there isn't a PHP port for thumbor-url, but there are specifications for creating a new port here:

https://github.com/globocom/thumbor/wiki/Libraries

If you do the PHP port we will happily include it on the page.

If you need any feedback/help feel free to contact any of us.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment