# PyCall problem

**URL:** https://discourse.julialang.org/t/pycall-problem/123977
**Category:** General Usage
**Tags:** question, package
**Created:** [December 19, 2024, 2:25am UTC](https://discourse.julialang.org/t/pycall-problem/123977 "2024-12-19T02:25:42Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![jiang\_ming\_zhang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jiang_ming_zhang/32/204063_2.png) [@jiang\_ming\_zhang](https://discourse.julialang.org/u/jiang_ming_zhang)
#### Post date: [December 19, 2024, 2:25am UTC](https://discourse.julialang.org/t/pycall-problem/123977/1 "2024-12-19T02:25:42Z")

</div>

my julia version is 1.10.0, and my system is windows 10.

```julia
julia> using PyCall

julia> using JLD

julia> @pyimport sympy.physics.wigner as wigner
ERROR: PyError (PyImport_ImportModule

The Python package sympy.physics.wigner could not be imported by pyimport. Usually this means
that you did not install sympy.physics.wigner in the Python version being used by PyCall.

PyCall is currently configured to use the Julia-specific Python distribution
installed by the Conda.jl package. To install the sympy.physics.wigner module, you can
use `pyimport_conda("sympy.physics.wigner", PKG)`, where PKG is the Anaconda
package that contains the module sympy.physics.wigner, or alternatively you can use the
Conda package directly (via `using Conda` followed by `Conda.add` etcetera).

Alternatively, if you want to use a different Python distribution on your
system, such as a system-wide Python (as opposed to the Julia-specific Python),
you can re-configure PyCall with that Python. As explained in the PyCall
documentation, set ENV["PYTHON"] to the path/name of the python executable
you want to use, run Pkg.build("PyCall"), and re-launch Julia.

```

I later installed sympy as

```julia
C:\Users\jmzhang>py -m pip install "sympy"

```

But the problem remains.

---

<div class="post-metadata">

### Author: ![jiang\_ming\_zhang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jiang_ming_zhang/32/204063_2.png) [@jiang\_ming\_zhang](https://discourse.julialang.org/u/jiang_ming_zhang)
#### Post date: [December 19, 2024, 2:37am UTC](https://discourse.julialang.org/t/pycall-problem/123977/2 "2024-12-19T02:37:00Z")

</div>

oh, the problem is that ‘sympy.physics.wigner’ is not installed yet.

Installing ‘sympy’ does not imply its submodules included?

```julia
PS C:\Users\jmzhang> python 
Python 3.11.5 | packaged by Anaconda, Inc. | (main, Sep 11 2023, 13:26:23) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sympy.physis.wigner as wigner 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'sympy.physis'

```

---

<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: [December 19, 2024, 3:00am UTC](https://discourse.julialang.org/t/pycall-problem/123977/3 "2024-12-19T03:00:38Z")

</div>

> [@jiang\_ming\_zhang](#):
>
> I later installed sympy as
> 
> `C:\Users\jmzhang>py -m pip install "sympy"`

Are you sure PyCall is configured to use this `python` version? The error message says: _PyCall is currently configured to use the Julia-specific Python distribution installed by the Conda.jl package_ (by default on Windows systems, PyCall installs its own Python distro via Conda.jl, entirely separate from any other Python installation on your system)

If you want it to use a different Python, e.g. the system-wide `python` program you’ve installed in your path, you need to configure PyCall to use this.

1. restart `julia`
2. set `ENV["PYTHON"]="python"` (assuming you want to use the `python` on your `PATH`)
3. open the `pkg>` prompt (by typing `]') and then type `build PyCall`

At that point you should be set (you only have to configure PyCall once).

---

<div class="post-metadata">

### Author: ![g-gundam](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/g-gundam/32/47593_2.png) [@g-gundam](https://discourse.julialang.org/u/g-gundam)
#### Post date: [December 19, 2024, 3:01am UTC](https://discourse.julialang.org/t/pycall-problem/123977/4 "2024-12-19T03:01:02Z")

</div>

It might not have installed into the place where Julia is looking for modules. You also misspelled **physics** as **physis**.

The original error message gave you a few suggestions. The one that looked appealing to me was:

> [@jiang\_ming\_zhang](#):
>
> ```julia
> alternatively you can use the Conda package directly (via `using Conda` followed by `Conda.add` etcetera).
> 
> ```

Have you tried doing:

```julia-repl
julia> ]
pkg> add Conda
pkg> <backspace>
julia> using Conda
julia> Conda.add("sympy")

```

?

---

<div class="post-metadata">

### Author: ![g-gundam](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/g-gundam/32/47593_2.png) [@g-gundam](https://discourse.julialang.org/u/g-gundam)
#### Post date: [December 19, 2024, 3:16am UTC](https://discourse.julialang.org/t/pycall-problem/123977/5 "2024-12-19T03:16:32Z")

</div>

I barely use python, so my previous post’s suggestion of using `Conda.add` didn’t work. However, you know what did work? From my shell:

```bash
conda add sympy

```

Then I could:

```julia-repl
julia> @pyimport sympy.physics.wigner as wigner

```

…successfully.

---

<div class="post-metadata">

### Author: ![jiang\_ming\_zhang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jiang_ming_zhang/32/204063_2.png) [@jiang\_ming\_zhang](https://discourse.julialang.org/u/jiang_ming_zhang)
#### Post date: [December 19, 2024, 3:21am UTC](https://discourse.julialang.org/t/pycall-problem/123977/6 "2024-12-19T03:21:01Z")

</div>

But how did you use conda? where to use it?

```julia
PS C:\Users\jmzhang> conda add sympy 
usage: conda-script.py [-h] [--no-plugins] [-V] COMMAND ...
conda-script.py: error: argument COMMAND: invalid choice: 'add' (choose from 'clean', 'compare', 'config', 'create', 'info', 'init', 'install', 'list', 'notices', 'package', 'remove', 'uninstall', 'rename', 'run', 
'search', 'update', 'upgrade', 'build', 'content-trust', 'convert', 'debug', 'develop', 'doctor', 'index', 'inspect', 'metapackage', 'render', 'skeleton', 'token', 'repo', 'verify', 'env', 'pack', 'server')        
PS C:\Users\jmzhang>

```

---

<div class="post-metadata">

### Author: ![g-gundam](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/g-gundam/32/47593_2.png) [@g-gundam](https://discourse.julialang.org/u/g-gundam)
#### Post date: [December 19, 2024, 4:24am UTC](https://discourse.julialang.org/t/pycall-problem/123977/7 "2024-12-19T04:24:16Z")

</div>

I made a mistake in my post. I meant to say:

```bash
conda install sympy

```

I don’t know why I typed out “add”. Maybe I had “add” on my mind from the Julia’s `Pkg.add()`. Sorry about that.
