# Importing python packages using PyCall throws up an error

**URL:** https://discourse.julialang.org/t/importing-python-packages-using-pycall-throws-up-an-error/60166
**Category:** New to Julia
**Tags:** question, package
**Created:** [April 28, 2021, 1:06pm UTC](https://discourse.julialang.org/t/importing-python-packages-using-pycall-throws-up-an-error/60166 "2021-04-28T13:06:45Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![varun7rs](https://avatars.discourse-cdn.com/v4/letter/v/c2a13f/32.png) [@varun7rs](https://discourse.julialang.org/u/varun7rs)
#### Post date: [April 28, 2021, 1:06pm UTC](https://discourse.julialang.org/t/importing-python-packages-using-pycall-throws-up-an-error/60166/1 "2021-04-28T13:06:46Z")

</div>

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:

```julia
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?

---

<div class="post-metadata">

### Author: ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)
#### Post date: [April 28, 2021, 1:11pm UTC](https://discourse.julialang.org/t/importing-python-packages-using-pycall-throws-up-an-error/60166/2 "2021-04-28T13:11:10Z")

</div>

> [@varun7rs](#):
>
> The same happens when I try using the math package as well.

Works fine for me:

```julia
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?

---

<div class="post-metadata">

### Author: ![varun7rs](https://avatars.discourse-cdn.com/v4/letter/v/c2a13f/32.png) [@varun7rs](https://discourse.julialang.org/u/varun7rs)
#### Post date: [April 28, 2021, 1:53pm UTC](https://discourse.julialang.org/t/importing-python-packages-using-pycall-throws-up-an-error/60166/3 "2021-04-28T13:53:28Z")

</div>

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

```julia
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

```

---

<div class="post-metadata">

### Author: ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)
#### Post date: [April 28, 2021, 2:08pm UTC](https://discourse.julialang.org/t/importing-python-packages-using-pycall-throws-up-an-error/60166/4 "2021-04-28T14:08:03Z")

</div>

> [@varun7rs](#):
>
> `/home/minerva/.julia/v0.6`

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

---

<div class="post-metadata">

### Author: ![varun7rs](https://avatars.discourse-cdn.com/v4/letter/v/c2a13f/32.png) [@varun7rs](https://discourse.julialang.org/u/varun7rs)
#### Post date: [April 28, 2021, 5:15pm UTC](https://discourse.julialang.org/t/importing-python-packages-using-pycall-throws-up-an-error/60166/5 "2021-04-28T17:15:20Z")

</div>

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

---

<div class="post-metadata">

### Author: ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)
#### Post date: [April 28, 2021, 5:23pm UTC](https://discourse.julialang.org/t/importing-python-packages-using-pycall-throws-up-an-error/60166/6 "2021-04-28T17:23:53Z")

</div>

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

---

<div class="post-metadata">

### Author: ![varun7rs](https://avatars.discourse-cdn.com/v4/letter/v/c2a13f/32.png) [@varun7rs](https://discourse.julialang.org/u/varun7rs)
#### Post date: [April 28, 2021, 5:31pm UTC](https://discourse.julialang.org/t/importing-python-packages-using-pycall-throws-up-an-error/60166/7 "2021-04-28T17:31:31Z")

</div>

Had it and have been using it since a few years 😅
