samuraisam / django-json-rpc

JSON-RPC Implementation for Django
MIT License
286 stars 83 forks source link

Import error with python 3 #69

Closed olymk2 closed 9 years ago

olymk2 commented 9 years ago

I have a django app setup in a virtualenv, i am currently porting this to python 3, I am hitting issues with django-json-rpc import.

basically i am getting the issue below, running python interactively I can see that indeed _json does not exist how ever i can change it to from json import dumps.

/src/django-json-rpc/jsonrpc/views.py", line 1, in <module>
from _json import dumps
ImportError: cannot import name 'dumps' ```

is this a known issue or am I missing a requirement ?

samuraisam commented 9 years ago

What version of Python 3 are you using? We might have to make it from ._json import dumps

olymk2 commented 9 years ago

default on ubuntu 15.04

python3 --version Python 3.4.3

olymk2 commented 9 years ago

worth noting I just deleted the _ and everything seemed to be working, though I have not thoroughly tested this yet but it got my django app running.

alex-moon commented 9 years ago

It's a name clash:

Python 2.7.6 (default, Mar 22 2014, 22:59:56) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import _json
>>> _json
<module '_json' from '/usr/lib/python2.7/lib-dynload/_json.x86_64-linux-gnu.so'>
>>>

A quick Google suggests that's an Android library. If it's installed in the system site packages (e.g. on a laptop where a developer's playing around with Android) it'll conflict. Simple from ._json should do the trick.

samuraisam commented 9 years ago

Derp, sorry for not noticing this. Will from ._json affect earlier python versions (eg 2.6?)

samuraisam commented 9 years ago

Meh, I just made it an absolute import. Will merge in and update PyPI

samuraisam commented 9 years ago

Ok, 0.7.1 is out which fixes this issue