Giter Site home page Giter Site logo

Comments (7)

Dancovich avatar Dancovich commented on September 26, 2024

You placed it in the right folder. It seems there is an import error in the JSON exporting script I use. I'll do some testing in Blender 2.77 and report back. Thanks for the report.

from libgdx_blender_g3d_exporter.

Dancovich avatar Dancovich commented on September 26, 2024

Sorry for taking so long to respond. I tested this on Blender 2.77 and 2.78 in Ubuntu Linux 16.04 and this error didn't occur.

The import error (cannot import name 'FLOAT_REPR') is being given to a Python library, this constant should be present on the "json" module which is part of Python.

I don't know why your combination of Blender and Manjaro Linux is giving this error, as far as I know Blender searches for it's own bundled Python library before using the system library but your error might be coming from Blender using Manjaro's Python and not finding this particular constant declared in the json module.

If you're still having this issue (or even using my library at all) in Blender 2.78 try making sure you're using the bundled Python in Blender.

from libgdx_blender_g3d_exporter.

stewlab avatar stewlab commented on September 26, 2024

I am having the same problem in Blender 2.76 on Ubuntu 16.04:
image

Problem Source

It looks like 'FLOAT_REPR' was removed from json.encoder in the transition from Python 3.5.1 to 3.5.2, according to the following diff:
https://fossies.org/diffs/Python/3.5.1_vs_3.5.2/Lib/json/encoder.py-diff.html

Blender 2.76 seems to default to Python 3.5.2, which is probably why some of us are getting this issue.

Temporary Solution (not really reccomended)

I was able to get around the issue by opening the Python console in Blender (Shift + F4), and manually setting the 'FLOAT_REPR' value by entering the following in the console:
import json
json.encoder.FLOAT_REPR = float.__repr__

I was then able to enable and use the g3d exporter plugin in the user preferences without any error. However, the steps in this method need to be repeated every time you restart Blender.

Permanent Solution

I was able to fix this permanently by modifying g3dj_json_encoder.py in the main io_scene_g3d plugin directory.

The problem is the following line in that file does not work in Python 3.5.2 (around line 20):
from json.encoder import encode_basestring_ascii, encode_basestring, FLOAT_REPR, INFINITY

So I just changed it to the following:
from json.encoder import encode_basestring_ascii, encode_basestring, INFINITY

Also, I needed to change the FLOAT_REPR usage (around line 63):
from
_repr=FLOAT_REPR

to
_repr=float.__repr__

I then saved the file, restarted Blender, enabled the plugin, and it worked as intended. I have not tested this with Python versions lower than 3.5.2, but I will submit a pull request once I verify that it works with versions below that.

Edit: merge request #10 submitted, as this code looks to work with Python 2.7. The recent Blender versions seem to support Python 3+, so this should be fine.

from libgdx_blender_g3d_exporter.

Dancovich avatar Dancovich commented on September 26, 2024

I'll just do some final testing but it seems you where on point on the cause. I'll accept the pull request after this final test.

Thanks for contributing.

from libgdx_blender_g3d_exporter.

SolarLune avatar SolarLune commented on September 26, 2024

Hello! I'm looking into using this exporter, but I stumbled on this same bug. Is the PR being held up for some reason?

from libgdx_blender_g3d_exporter.

Dancovich avatar Dancovich commented on September 26, 2024

@SolarLune, I swear I though it was already merged as it was already tested.

Done now, it should work. Please report if it's still giving an error.

from libgdx_blender_g3d_exporter.

SolarLune avatar SolarLune commented on September 26, 2024

Hey, that solved it. Thanks!

from libgdx_blender_g3d_exporter.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.