I am having difficulty installing SymPy. I keep getting the following error message after I type “using SymPy” into the REPL:
julia> using SymPy
[ Info: Installing sympy via the Conda sympy package…
[ Info: Running conda install -y sympy
in root environment
failed to create process.
ERROR: InitError: PyError (PyImport_ImportModule
The Python package sympy could not be imported by pyimport. Usually this means
that you did not install sympy 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 module, you can
use pyimport_conda("sympy", PKG)
, where PKG is the Anaconda
package the contains the module sympy, 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.
) <class ‘ModuleNotFoundError’>
ModuleNotFoundError(“No module named ‘sympy’”)
Stacktrace:
[1] pyimport(name::String)
@ PyCall C:\Users\Richard Savage.julia\packages\PyCall\BD546\src\PyCall.jl:550
[2] pyimport_conda(modulename::String, condapkg::String, channel::String)
@ PyCall C:\Users\Richard Savage.julia\packages\PyCall\BD546\src\PyCall.jl:714
[3] pyimport_conda
@ C:\Users\Richard Savage.julia\packages\PyCall\BD546\src\PyCall.jl:707 [inlined]
[4] init()
@ SymPy C:\Users\Richard Savage.julia\packages\SymPy\VpBut\src\SymPy.jl:121
[5] _include_from_serialized(path::String, depmods::Vector{Any})
@ Base .\loading.jl:696
[6] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String)
@ Base .\loading.jl:782
[7] _require(pkg::Base.PkgId)
@ Base .\loading.jl:1020
[8] require(uuidkey::Base.PkgId)
@ Base .\loading.jl:936
[9] require(into::Module, mod::Symbol)
@ Base .\loading.jl:923
during initialization of module SymPy
I want to use the Julia-specific Python distribution
installed by the Conda.jl package. The error message says to use “pyimport_conda(“sympy”, PKG)” to install Sympy. What do I use for “PKG”?
Here is some additional info that may be relevant:
julia> Pkg.installed()
┌ Warning: Pkg.installed() is deprecated
└ @ Pkg C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\Pkg.jl:570
Dict{String, VersionNumber} with 19 entries:
“Hwloc” => v"2.0.0"
“Distributions” => v"0.25.11"
“Atom” => v"0.12.33"
“BenchmarkTools” => v"1.1.1"
“Interpolations” => v"0.13.3"
“TimerOutputs” => v"0.5.12"
“Juno” => v"0.8.4"
“Conda” => v"1.5.2"
“PyCall” => v"1.92.3"
“CalculusWithJulia” => v"0.0.7"
“SymPy” => v"1.0.50"
“Compat” => v"3.32.0"
“Plots” => v"1.15.2"
“GeometryBasics” => v"0.3.13"
“WebIO” => v"0.8.15"
“StaticArrays” => v"1.2.10"
“GLMakie” => v"0.4.4"
“DistributedArrays” => v"0.6.5"
“SpecialFunctions” => v"0.10.3"
julia> import Conda
julia> Conda.PYTHONDIR
“C:\Users\Richard Savage\.julia\conda\3”
julia> using PyCall
julia> PyCall.python
“C:\Users\Richard Savage\.julia\conda\3\python.exe”