[IronPython] Cannot import 'Networkx' into Ironpython

Federico Vaggi vaggi at cosbi.eu
Tue Jan 25 17:07:05 CET 2011


  Hi Jeff,

my python directory looks like this:

C:\Python27\Lib\site-packages>dir
  Volume in drive C is OS
  Volume Serial Number is CA49-670D

  Directory of C:\Python27\Lib\site-packages

25/01/2011  16:37 <DIR>          .
25/01/2011  16:37 <DIR>          ..
20/09/2006  18:05               126 easy_install.py
25/01/2011  15:10               312 easy_install.pyc
25/01/2011  15:10               312 easy_install.pyo
25/01/2011  16:16 <DIR>          networkx
25/01/2011  16:16             1,526 networkx-1.4-py2.7.egg-info
25/01/2011  16:36 <DIR>          numpy
18/11/2010  21:06             1,647 numpy-1.5.1-py2.7.egg-info
19/10/2009  14:35            85,435 pkg_resources.py
25/01/2011  15:15            90,779 pkg_resources.pyc
25/01/2011  15:10            90,779 pkg_resources.pyo
13/11/2010  20:07               121 README.txt
25/01/2011  16:37 <DIR>          scipy
23/01/2011  20:07             1,758 scipy-0.9.0rc1-py2.7.egg-info
25/01/2011  15:15 <DIR>          setuptools
25/01/2011  15:10 <DIR>          setuptools-0.6c11-py2.7.egg-info
20/09/2006  18:05             2,362 site.py
25/01/2011  15:10             1,719 site.pyc
25/01/2011  15:10             1,719 site.pyo
               13 File(s)        278,595 bytes
                7 Dir(s)  183,639,756,800 bytes free

C:\Python27\Lib\site-packages>cd networkx

C:\Python27\Lib\site-packages\networkx>dir
  Volume in drive C is OS
  Volume Serial Number is CA49-670D

  Directory of C:\Python27\Lib\site-packages\networkx

25/01/2011  16:16 <DIR>          .
25/01/2011  16:16 <DIR>          ..
25/01/2011  16:16 <DIR>          algorithms
25/01/2011  16:16 <DIR>          classes
23/01/2011  15:38            30,753 convert.py
25/01/2011  16:16            29,322 convert.pyc
25/01/2011  16:16 <DIR>          drawing
23/01/2011  15:38             1,540 exception.py
25/01/2011  16:16             2,498 exception.pyc
25/01/2011  16:16 <DIR>          generators
25/01/2011  16:16 <DIR>          linalg
25/01/2011  16:16 <DIR>          readwrite
23/01/2011  15:39             8,226 release.py
25/01/2011  16:16             7,238 release.pyc
23/01/2011  15:38               740 sys.py
25/01/2011  16:16               744 sys.pyc
25/01/2011  16:16 <DIR>          tests
23/01/2011  15:38             9,723 utils.py
25/01/2011  16:16            11,061 utils.pyc
25/01/2011  16:16               650 version.py
25/01/2011  16:16               665 version.pyc
23/01/2011  15:38             1,878 __init__.py
25/01/2011  16:16             1,695 __init__.pyc
               14 File(s)        106,733 bytes
                9 Dir(s)  183,639,719,936 bytes free


I added:

sys.path.append(r"C:\Python27\Lib\site-packages\networkx")

to site.py in the ironpython folder and this is not enough to get 
ironpython to see it, but it is enough to get cpython to see it without 
any further changes.

Thanks for the subprocess suggestion, I'll change it as soon as I get 
there.  Do I simply copy that file and put it anywhere on the ironpython 
path or do I have to replace an existing file?

Federico

On 25/01/2011 16:54, Jeff Hardy wrote:
> It looks like networkx is a pure-Python package, so it should work.
> What are you adding sys.path? I cloned the repo into the networkx
> folder, which contains a networkx folder - sys.path should point to
> the outer folder.
>
>>>> sys.path.append(r'C:\Users\<user>\Documents\Repositories\networkx')
> Doing that, it complains that it can't find subprocess, which is a bug
> in the alpha - I'm not sure it's fixed in B1, but it will be in B2. In
> the meantime you can copy subprocess.py from
> https://github.com/IronLanguages/main/blob/master/External.LCA_RESTRICTED/Languages/IronPython/27/Lib/subprocess.py
> into the Lib folder for your IronPython installation.
>
> - Jeff
>
> On Tue, Jan 25, 2011 at 8:31 AM, Federico Vaggi<vaggi at cosbi.eu>  wrote:
>>   Hello,
>>
>> I am a very new user to Ironpython, so hopefully I am not missing anything
>> obvious.  I read the FAQ and searched the Ironpython site and I couldn't
>> find a solution to the problem I was having.
>>
>> I have installed both CPython 2.7 and Ironpython 2.7 (the alpha version) and
>> I am interested in using the networkx library (http://networkx.lanl.gov/)
>> under Ironpython.
>>
>> I installed networkx here:
>>
>> C:\Python27\Lib\site-packages\networkx
>>
>> using the cpython interpreter, the installation worked fine:
>>
>>>>> import networkx as nx
>>>>> G=nx.Graph()
>>>>> G
>> <networkx.classes.graph.Graph object at 0x02C04250>
>>
>> if I try to use the ironpython interpreter:
>>
>> I get a:
>> File "<stdin>", line 1, in<module>
>> ImportError: No module named networkx
>>
>> I tried manually adding the site.py file, to add networkx manually to the
>> path, but even after adding it (and checking that it shows up in
>> system.path) ironpython still doesn't see it.
>>
>> Anyone have useful advice here?
>>
>> Thank you very much,
>>
>> Federico
>>
>>
>> _______________________________________________
>> Users mailing list
>> Users at lists.ironpython.com
>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>>
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com




More information about the Ironpython-users mailing list