# Having trouble importing hypernetx with PyCall

**URL:** <https://discourse.julialang.org/t/having-trouble-importing-hypernetx-with-pycall/82395>\
**Category:** General Usage\
**Tags:** question, package, pycall\
**Created:** [June 8, 2022, 12:00am UTC](https://discourse.julialang.org/t/having-trouble-importing-hypernetx-with-pycall/82395 "2022-06-08T00:00:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Codzilla](https://avatars.discourse-cdn.com/v4/letter/c/7cd45c/32.png) [@Codzilla](https://discourse.julialang.org/u/Codzilla)\
**Post date:** [June 8, 2022, 12:00am UTC](https://discourse.julialang.org/t/having-trouble-importing-hypernetx-with-pycall/82395/1 "2022-06-08T00:00:27Z")

</div>

While trying to use [SimpleHypergraphs.jl](https://github.com/pszufe/SimpleHypergraphs.jl) visualization tools which require hypernetx (a python library), I encountered an error while running the following (which comes from the README of [SimpleHypergraphs.jl](https://github.com/pszufe/SimpleHypergraphs.jl) ):

```julia
using PyCall
using Conda
Conda.runconda(`install matplotlib --yes`)
Conda.runconda(`install networkx --yes`)
Conda.runconda(`install pandas --yes`)
run(`$(PyCall.python) -m pip install hypernetx`)
pyimport("hypernetx")

> ERROR: PyError (PyImport_ImportModule
> The Python package hypernetx could not be imported by pyimport. Usually, this means
> that you did not install hypernetx in the Python version being used by PyCall.[...]

```

Similarly doing `using SimpleHypergraphs` gives me the following warning  
`┌ Warning: The plotting functionality of HyperNetX will not work! │ Conda Python HyperNetX not found.`

The package is in my Conda environment and in my python environment (verified by running `Conda.list()` and `run(`$(PyCall.python) -m pip list`)` respectively in the same Julia session).

Am I doing something wrong? If so, what am I supposed to do?

```julia
julia> versioninfo()
Julia Version 1.7.1
Commit ac5cc99908 (2021-12-22 19:35 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i5-6200U CPU @ 2.30GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.1 (ORCJIT, skylake)

```

---

<div class="post-metadata">

**Author:** ![icweaver](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/icweaver/32/45764_2.png) [@icweaver](https://discourse.julialang.org/u/icweaver)\
**Post date:** [June 8, 2022, 1:02am UTC](https://discourse.julialang.org/t/having-trouble-importing-hypernetx-with-pycall/82395/2 "2022-06-08T01:02:46Z")

</div>

fwiw, using [PythonCall.jl](https://github.com/cjdoris/PythonCall.jl)/[CondaPkg.jl](https://github.com/cjdoris/CondaPkg.jl) seems to work well:

```julia
pkg> activate .

(hypernetx) pkg> add CondaPkg

julia> using CondaPkg

(hypernetx) pkg> conda add matplotlib networkx pandas decorator

(hypernetx) pkg> conda pip_add hypernetx

(hypernetx) pkg> conda st
CondaPkg Status /home/mango/Projects/hypernetx/CondaPkg.toml
Packages
  decorator v5.1.1
  matplotlib v3.5.2
  networkx v2.8.3
  pandas v1.4.2
Pip packages
  hypernetx v1.2.4

(hypernetx) pkg> add PythonCall

julia> using PythonCall

julia> @py import hypernetx as hnx

julia> hnx
Python module: <module 'hypernetx' from '/home/mango/Projects/hypernetx/.CondaPkg/env/lib/python3.10/site-packages/hypernetx/ __init__.py'>

```

Just a quick note that I included the `decorators` package because it seemed to be required for the installation to work, same when trying in a plain python shell

> Similarly doing `using SimpleHypergraphs` gives me the following warning  
> `┌ Warning: The plotting functionality of HyperNetX will not work! │ Conda Python HyperNetX not found.`

I’m not able to reproduce this on linux, so this might be a windows specific issue?

---

<div class="post-metadata">

**Author:** ![Codzilla](https://avatars.discourse-cdn.com/v4/letter/c/7cd45c/32.png) [@Codzilla](https://discourse.julialang.org/u/Codzilla)\
**Post date:** [June 14, 2022, 4:00pm UTC](https://discourse.julialang.org/t/having-trouble-importing-hypernetx-with-pycall/82395/3 "2022-06-14T16:00:19Z")

</div>

The missing dependency on “decorator” was the problem!

Thank you!

I’ll open an issue on [SimpleHypergraphs.jl](https://github.com/pszufe/SimpleHypergraphs.jl) to add it in the README
