Cannot import name psyco_gevent

498 views Asked by At

I have an import error with

from psycogreen.gevent import psyco_gevent
psyco_gevent.make_psycopg_green()

it says:

ImportError: cannot import name psyco_gevent

I installed psycopg2 and psycogreen; and I followed this nice article about Django, Gevent, and Socket.io. This article also talks about it (it might be the source of the first article) and talks about a file named psyco_gevent.py on bitbucket which is not available anymore (404 error).

2

There are 2 answers

0
arthur.sw On

For the psycogreen, it does look like its changed a bit. Check it out on bitbucket: https://bitbucket.org/dvarrazzo/psycogreen/overview

It looks like this code:

from psycogreen.gevent import psyco_gevent
psyco_gevent.make_psycopg_green()

Should be changed to the same as the other psycogreen calls:

from psycogreen.gevent import patch_psycopg
patch_psycopg()
0
J.Doe On

I suffer from a similar question like this when I import a model named as greenlet:

ImportError: cannot import name 'greenlet'

I don't know exactly the reason but I resolved the problem by renaming the file name greenlet.py to gl.py. Maybe we can't name a file by a model's name.