PyCall not properly installed

I am not able to use any package which has some connection with the PyCall package. I tried following the instructions in one of the cases (for using ScikitLearn package) and have given the output below. I tried resolving the error by following online resolved issues and felt like I am making it worse. Please help me fix this issue. I am using Julia v1.4.1 in Ubuntu 20.04 WSL.

using ScikitLearn
β”Œ Info: Precompiling ScikitLearn [3646fa90-6ef7-5e7e-9f22-8aca16db6324]
β”” @ Base loading.jl:1260
ERROR: LoadError: LoadError: PyCall not properly installed. Please run Pkg.build("PyCall")
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] top-level scope at /home/sambit98/.juliapro/JuliaPro_v1.4.1-1/packages/PyCall/zqDXB/src/startup.jl:44
 [3] include(::Module, ::String) at ./Base.jl:377
 [4] include(::String) at /home/sambit98/.juliapro/JuliaPro_v1.4.1-1/packages/PyCall/zqDXB/src/PyCall.jl:1
 [5] top-level scope at /home/sambit98/.juliapro/JuliaPro_v1.4.1-1/packages/PyCall/zqDXB/src/PyCall.jl:34
 [6] include(::Module, ::String) at ./Base.jl:377
 [7] top-level scope at none:2
 [8] eval at ./boot.jl:331 [inlined]
 [9] eval(::Expr) at ./client.jl:449
 [10] top-level scope at ./none:3
in expression starting at /home/sambit98/.juliapro/JuliaPro_v1.4.1-1/packages/PyCall/zqDXB/src/startup.jl:41
in expression starting at /home/sambit98/.juliapro/JuliaPro_v1.4.1-1/packages/PyCall/zqDXB/src/PyCall.jl:34
ERROR: LoadError: LoadError: Failed to precompile PyCall [438e738f-606a-5dbb-bf0a-cddfbfd45ab0] to /home/sambit98/.juliapro/JuliaPro_v1.4.1-1/compiled/v1.4/PyCall/GkzkC_XmPoC.ji.
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] compilecache(::Base.PkgId, ::String) at ./loading.jl:1272
 [3] _require(::Base.PkgId) at ./loading.jl:1029
 [4] require(::Base.PkgId) at ./loading.jl:927
 [5] require(::Module, ::Symbol) at ./loading.jl:922
 [6] include(::Module, ::String) at ./Base.jl:377
 [7] include(::String) at /home/sambit98/.juliapro/JuliaPro_v1.4.1-1/packages/ScikitLearn/bo2Pt/src/ScikitLearn.jl:10
 [8] top-level scope at /home/sambit98/.juliapro/JuliaPro_v1.4.1-1/packages/ScikitLearn/bo2Pt/src/ScikitLearn.jl:12
 [9] include(::Module, ::String) at ./Base.jl:377
 [10] top-level scope at none:2
 [11] eval at ./boot.jl:331 [inlined]
 [12] eval(::Expr) at ./client.jl:449
 [13] top-level scope at ./none:3
in expression starting at /home/sambit98/.juliapro/JuliaPro_v1.4.1-1/packages/ScikitLearn/bo2Pt/src/Skcore.jl:11
in expression starting at /home/sambit98/.juliapro/JuliaPro_v1.4.1-1/packages/ScikitLearn/bo2Pt/src/ScikitLearn.jl:12
Failed to precompile ScikitLearn [3646fa90-6ef7-5e7e-9f22-8aca16db6324] to /home/sambit98/.juliapro/JuliaPro_v1.4.1-1/compiled/v1.4/ScikitLearn/tbUuI_XmPoC.ji.

Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] compilecache(::Base.PkgId, ::String) at ./loading.jl:1272
 [3] _require(::Base.PkgId) at ./loading.jl:1029
 [4] require(::Base.PkgId) at ./loading.jl:927
 [5] require(::Module, ::Symbol) at ./loading.jl:922
 [6] top-level scope at In[1]:1

1
Pkg.build("PyCall")
   Building Conda ─→ `~/.juliapro/JuliaPro_v1.4.1-1/packages/Conda/3rPhK/deps/build.log`
β”Œ Error: Error building `Conda`: 
β”‚ ERROR: LoadError: ArgumentError: Package Pkg not found in current path:
β”‚ - Run `import Pkg; Pkg.add("Pkg")` to install the Pkg package.
β”‚ 
β”‚ Stacktrace:
β”‚  [1] require(::Module, ::Symbol) at ./loading.jl:892
β”‚  [2] include(::Module, ::String) at ./Base.jl:377
β”‚  [3] load_julia_startup() at ./client.jl:316
β”‚  [4] exec_options(::Base.JLOptions) at ./client.jl:259
β”‚  [5] _start() at ./client.jl:484
β”‚ in expression starting at /mnt/d/SAMBIT/JULIA/JuliaInstallation/JuliaPro-1.4.1-1/Julia/etc/julia/startup.jl:5
β”” @ Pkg.Operations /home/buildbot/build-worker/worker/juliapro-release-centos7-0_6/build/tmp_julia/share/julia/stdlib/v1.4/Pkg/src/Operations.jl:892
   Building PyCall β†’ `~/.juliapro/JuliaPro_v1.4.1-1/packages/PyCall/zqDXB/deps/build.log`
β”Œ Error: Error building `PyCall`: 
β”‚ ERROR: LoadError: ArgumentError: Package Pkg not found in current path:
β”‚ - Run `import Pkg; Pkg.add("Pkg")` to install the Pkg package.
β”‚ 
β”‚ Stacktrace:
β”‚  [1] require(::Module, ::Symbol) at ./loading.jl:892
β”‚  [2] include(::Module, ::String) at ./Base.jl:377
β”‚  [3] load_julia_startup() at ./client.jl:316
β”‚  [4] exec_options(::Base.JLOptions) at ./client.jl:259
β”‚  [5] _start() at ./client.jl:484
β”‚ in expression starting at /mnt/d/SAMBIT/JULIA/JuliaInstallation/JuliaPro-1.4.1-1/Julia/etc/julia/startup.jl:5
β”” @ Pkg.Operations /home/buildbot/build-worker/worker/juliapro-release-centos7-0_6/build/tmp_julia/share/julia/stdlib/v1.4/Pkg/src/Operations.jl:892
Pkg
1
import Pkg; Pkg.add("Pkg")
   Updating registry at `~/.juliapro/JuliaPro_v1.4.1-1/registries/JuliaPro`
  Resolving package versions...
   Updating `~/.juliapro/JuliaPro_v1.4.1-1/environments/v1.4/Project.toml`
 [no changes]
   Updating `~/.juliapro/JuliaPro_v1.4.1-1/environments/v1.4/Manifest.toml`
 [no changes]

I’ve never used PyCall or ScikitLearn, but it looks like perhaps those error messages have led you a little astray.

You probably don’t want Pkg in your Project.toml, so I’d start by undoing the Pkg.add("Pkg") step.

I’d just hit the backbrace β€˜]’ to enter package mode and do

pkg> rm Pkg

For safe, measure, I’d suggest trying:

pkg> st

and see what you have in there. You should have at least ScikitLearn.

Your first error message indicates that you need to rebuild PyCall. For that, I’d try

pkg> build PyCall

How far does that get you?

Note:

Pkg is a standard library, so unless your package is doing something with Pkg, you don’t need to add it, but you do need to either import it or use the package mode by hitting β€˜]’ like above.

I usually do the latter when I’m in the REPL so I don’t need to import Pkg.

1 Like

I got the below output after executing the 3 commands you mentioned. I have ScikitLearn in the output of line 2, but the problem still persists, as seen in output of line 3.

1
]rm Pkg
   Updating `~/.juliapro/JuliaPro_v1.4.1-1/environments/v1.4/Project.toml`
  [44cfe95a] - Pkg 
   Updating `~/.juliapro/JuliaPro_v1.4.1-1/environments/v1.4/Manifest.toml`
 [no changes]
]
1
]st
Status `~/.juliapro/JuliaPro_v1.4.1-1/environments/v1.4/Project.toml`
  [69666777] Arrow v0.2.4
  [c52e3926] Atom v0.12.10 ⚲
  [6e4b80f9] BenchmarkTools v0.5.0
  [8f4d0f93] Conda v1.4.1
  [a93c6f00] DataFrames v0.20.2
  [aaf54ef3] DistributedArrays v0.6.4
  [31c24e10] Distributions v0.23.2
  [becb17da] Feather v0.5.5
  [587475ba] Flux v0.10.4
  [0e44f5e4] Hwloc v1.0.3
  [7073ff75] IJulia v1.21.2
  [a98d9a8b] Interpolations v0.12.9
  [aa1ae85d] JuliaInterpreter v0.7.14
  [e5e0dc1b] Juno v0.8.1 ⚲
  [cc2ba9b6] MLDataUtils v0.5.1
  [872c559c] NNlib v0.6.6
  [4722fa14] PkgAuthentication v0.1.2
  [91a5bcdd] Plots v1.2.2
  [c46f51b8] ProfileView v0.6.5
  [438e738f] PyCall v1.91.4
  [3646fa90] ScikitLearn v0.5.1
  [a759f4b9] TimerOutputs v0.5.5
  [1cfade01] UnicodeFun v0.4.1
  [44d3d7a6] Weave v0.9.4
C
1
]build PyCall
   Building Conda ─→ `~/.juliapro/JuliaPro_v1.4.1-1/packages/Conda/3rPhK/deps/build.log`
β”Œ Error: Error building `Conda`: 
β”‚ ERROR: LoadError: ArgumentError: Package Pkg not found in current path:
β”‚ - Run `import Pkg; Pkg.add("Pkg")` to install the Pkg package.
β”‚ 
β”‚ Stacktrace:
β”‚  [1] require(::Module, ::Symbol) at ./loading.jl:892
β”‚  [2] include(::Module, ::String) at ./Base.jl:377
β”‚  [3] load_julia_startup() at ./client.jl:316
β”‚  [4] exec_options(::Base.JLOptions) at ./client.jl:259
β”‚  [5] _start() at ./client.jl:484
β”‚ in expression starting at /mnt/d/SAMBIT/JULIA/JuliaInstallation/JuliaPro-1.4.1-1/Julia/etc/julia/startup.jl:5
β”” @ Pkg.Operations /home/buildbot/build-worker/worker/juliapro-release-centos7-0_6/build/tmp_julia/share/julia/stdlib/v1.4/Pkg/src/Operations.jl:892
   Building PyCall β†’ `~/.juliapro/JuliaPro_v1.4.1-1/packages/PyCall/zqDXB/deps/build.log`
β”Œ Error: Error building `PyCall`: 
β”‚ ERROR: LoadError: ArgumentError: Package Pkg not found in current path:
β”‚ - Run `import Pkg; Pkg.add("Pkg")` to install the Pkg package.
β”‚ 
β”‚ Stacktrace:
β”‚  [1] require(::Module, ::Symbol) at ./loading.jl:892
β”‚  [2] include(::Module, ::String) at ./Base.jl:377
β”‚  [3] load_julia_startup() at ./client.jl:316
β”‚  [4] exec_options(::Base.JLOptions) at ./client.jl:259
β”‚  [5] _start() at ./client.jl:484
β”‚ in expression starting at /mnt/d/SAMBIT/JULIA/JuliaInstallation/JuliaPro-1.4.1-1/Julia/etc/julia/startup.jl:5
β”” @ Pkg.Operations /home/buildbot/build-worker/worker/juliapro-release-centos7-0_6/build/tmp_julia/share/julia/stdlib/v1.4/Pkg/src/Operations.jl:892

Ok. Maybe you do need to import Pkg. So I’d try,

julia> import Pkg; Pkg.build("PyCall");

How is that?

1 Like

I had tried that already. It doesn’t work. The following is the output.

   Building Conda ─→ `~/.juliapro/JuliaPro_v1.4.1-1/packages/Conda/3rPhK/deps/build.log`
β”Œ Error: Error building `Conda`: 
β”‚ ERROR: LoadError: ArgumentError: Package Pkg not found in current path:
β”‚ - Run `import Pkg; Pkg.add("Pkg")` to install the Pkg package.
β”‚ 
β”‚ Stacktrace:
β”‚  [1] require(::Module, ::Symbol) at ./loading.jl:892
β”‚  [2] include(::Module, ::String) at ./Base.jl:377
β”‚  [3] load_julia_startup() at ./client.jl:316
β”‚  [4] exec_options(::Base.JLOptions) at ./client.jl:259
β”‚  [5] _start() at ./client.jl:484
β”‚ in expression starting at /mnt/d/SAMBIT/JULIA/JuliaInstallation/JuliaPro-1.4.1-1/Julia/etc/julia/startup.jl:5
β”” @ Pkg.Operations /home/buildbot/build-worker/worker/juliapro-release-centos7-0_6/build/tmp_julia/share/julia/stdlib/v1.4/Pkg/src/Operations.jl:892
   Building PyCall β†’ `~/.juliapro/JuliaPro_v1.4.1-1/packages/PyCall/zqDXB/deps/build.log`
β”Œ Error: Error building `PyCall`: 
β”‚ ERROR: LoadError: ArgumentError: Package Pkg not found in current path:
β”‚ - Run `import Pkg; Pkg.add("Pkg")` to install the Pkg package.
β”‚ 
β”‚ Stacktrace:
β”‚  [1] require(::Module, ::Symbol) at ./loading.jl:892
β”‚  [2] include(::Module, ::String) at ./Base.jl:377
β”‚  [3] load_julia_startup() at ./client.jl:316
β”‚  [4] exec_options(::Base.JLOptions) at ./client.jl:259
β”‚  [5] _start() at ./client.jl:484
β”‚ in expression starting at /mnt/d/SAMBIT/JULIA/JuliaInstallation/JuliaPro-1.4.1-1/Julia/etc/julia/startup.jl:5
β”” @ Pkg.Operations /home/buildbot/build-worker/worker/juliapro-release-centos7-0_6/build/tmp_julia/share/julia/stdlib/v1.4/Pkg/src/Operations.jl:892

Maybe there is some issue with Conda installation? I am seeing the Error: Error building `Conda` line a lot in these error messages.

I just installed Julia in Windows through Atom and successfully installed the packages I wanted. I am guessing there is some issue either with me using WSL, or using Jupyter Notebook, or a combination of both. I guess this is the only way I have right now to make use of the packages I want.
Thank you EricForgy for trying to help me on this issue.

I’m glad you got it to work. Sorry I wasn’t of more help :sweat_smile:

PS: Welcome to Julia! :julia::handshake::blush:

1 Like