Skip to content
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

using jSON--please help! #6125

Closed
ghost opened this issue Feb 15, 2016 · 6 comments
Closed

using jSON--please help! #6125

ghost opened this issue Feb 15, 2016 · 6 comments
Assignees
Labels

Comments

@ghost
Copy link

ghost commented Feb 15, 2016

Hi I am trying to use a json package in python.

I confirmed that my iron-python installation folder already comes with a json.py file.
But dynamo does not seem to recognize it. Adding a 'import json' causes an error in the script node. I am not doing it correctly? It works with other packages like 'itertools'
json

@mostaphaRoudsari
Copy link

You should add Python libraries path to sys.path before importing the library

image

import sys
sys.path.append(r"C:\Program Files (x86)\IronPython 2.7\Lib")

import json

@ghost
Copy link
Author

ghost commented Feb 15, 2016

Thanks, this worked.

I have two follow up questions:

1- Wondering why adding to path is required. For example, I can import itertools with
just the import statement. Both itertool and json live in the same
directory. Or is it that itertool is coded in by default?
2- the script editor in dynamo does not show a list available methods for
json after the dot operator.. for example: ' json.loads('["foo",
{"bar":["baz", null, 1.0, 2]}]'). It does that just fine for itertools.

On Mon, Feb 15, 2016 at 8:20 AM, Mostapha Sadeghipour Roudsari <
[email protected]> wrote:

You should add Python libraries path to sys.path before importing the
library

[image: image]
https://cloud.githubusercontent.com/assets/2915573/13054099/e7d115aa-d3d5-11e5-89a4-4055f7ffd6c4.png

import sys
sys.path.append(r"C:\Program Files (x86)\IronPython 2.7\Lib")
import json


Reply to this email directly or view it on GitHub
#6125 (comment).

@mostaphaRoudsari
Copy link

mostaphaRoudsari commented Feb 26, 2016

If you check sys.path you'll see that Python node in dynamo doesn't have a path to IronPython folder. You need to add it yourself so it can find the libraries.

I don't know how auto-complete works in Python node. It's probably broken but it shouldn't change how your code works.

@mjkkirschner
Copy link
Member

reopening - as I did not notice the last question was about the python autocomplete.

@mjkkirschner mjkkirschner reopened this Apr 29, 2016
@ikeough ikeough added the Python label May 1, 2016
@johnpierson
Copy link
Member

PRs that should address some of the issues here, #8420, #9180

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants