Importing python packages using PyCall throws up an error

I’m trying to call some functions in the NetworkX package in my program using PyCall. However I get this error when I try doing this:

using PyCall
nx = pyimport("networkx")
PyObject <module 'networkx' from '/home/minerva/.local/lib/python2.7/site-packages/networkx/__init__.pyc'>
g = nx.parse_gml("$(path)/Bics.gml")
ERROR: type PyObject has no field parse_gml

The same happens when I try using the math package as well. Any idea on why this is happening?

Works fine for me:

julia> math = pyimport("math")
PyObject <module 'math' from '/............/.julia/conda/3/lib/python3.7/lib-dynload/math.cpython-37m-darwin.so'>

julia> math.sin(3)
0.1411200080598672

Can you give an example that fails with the math package?

Here is the example I tried. I think there must be some issue regarding the versions of Python

using PyCall
math = pyimport("math")
PyObject <module 'math' from '/home/minerva/.julia/v0.6/Conda/deps/usr/lib/python3.8/lib-dynload/math.cpython-38-x86_64-linux-gnu.so'>
math.sin(math.pi/4)
ERROR: type PyObject has no field sin

You are using an ancient version of Julia. Have you tried Julia 1.6?

2 Likes

It works with the newer version. Thanks for pointing this out

I’m just curious. Where did you get Julia v0.6 from?

Had it and have been using it since a few years :sweat_smile:

1 Like