Fail to build `PyCall` in Julia 1.6.3

Hi everyone,

I am a beginner in Julia and I’m trying to install the PyCall package in Julia v1.6.3 (I’m using Jupyter notebook) on Windows 10. However, I encounter the following error messages and I cannot find any answer on Google.

Pkg.build("PyCall")

The error message I got from Jupyter notebook is:

 Building Conda ─→ `C:\Users\miaoc\.julia\scratchspaces\44cfe95a-1eb2-52ea-b672-e2afdf69b78f\299304989a5e6473d985212c28928899c74e9421\build.log`
    Building PyCall → `C:\Users\miaoc\.julia\scratchspaces\44cfe95a-1eb2-52ea-b672-e2afdf69b78f\169bb8ea6b1b143c5cf57df6d34d022a7b60c6db\build.log`
Error building `PyCall`, showing the last 100 of log: 
      File "C:\Users\miaoc\.julia\conda\3\lib\site-packages\urllib3\util\ssl_.py", line 453, in ssl_wrap_socket
        ssl_sock = _ssl_wrap_socket_impl(sock, context, tls_in_tls)
      File "C:\Users\miaoc\.julia\conda\3\lib\site-packages\urllib3\util\ssl_.py", line 495, in _ssl_wrap_socket_impl
        return ssl_context.wrap_socket(sock)
      File "C:\Users\miaoc\.julia\conda\3\lib\ssl.py", line 500, in wrap_socket
        return self.sslsocket_class._create(
      File "C:\Users\miaoc\.julia\conda\3\lib\ssl.py", line 997, in _create
        raise ValueError("check_hostname requires server_hostname")
    ValueError: check_hostname requires server_hostname

`$ C:\Users\miaoc\.julia\conda\3\Scripts\conda-script.py install -y numpy`

  environment variables:
                 CIO_TEST=<not set>
                  CONDARC=C:\Users\miaoc\.julia\conda\3\condarc-julia.yml
             CONDA_PREFIX=C:\Users\miaoc\.julia\conda\3
               CONDA_ROOT=C:\Users\miaoc\.julia\conda\3
           CURL_CA_BUNDLE=<not set>
                 HOMEPATH=\Users\miaoc
          JULIA_LOAD_PATH=@;C:\Users\miaoc\AppData\Local\Temp\jl_0iEtUu
                     PATH=C:\Users\miaoc\.julia\conda\3\Library\bin;D:\ProgramData\Anaconda3;D:\
                          ProgramData\Anaconda3\Library\mingw-w64\bin;D:\ProgramData\Anaconda3\L
                          ibrary\usr\bin;D:\ProgramData\Anaconda3\Library\bin;D:\ProgramData\Ana
                          conda3\Scripts;D:\ProgramData\Miniconda3;D:\ProgramData\Miniconda3\Lib
                          rary\mingw-w64\bin;D:\ProgramData\Miniconda3\Library\usr\bin;D:\Progra
                          mData\Miniconda3\Library\bin;D:\ProgramData\Miniconda3\Scripts;C:\WIND
                          OWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\W
                          indowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;D:\Program
                          Files\Git\cmd;C:\Program Files\Pandoc\;D:\Strawberry\c\bin;D:\Strawber
                          ry\perl\site\bin;D:\Strawberry\perl\bin;C:\Users\miaoc\AppData\Local\a
                          ctivestate\cache\bin;C:\Users\miaoc\AppData\Local\ActiveState\StateToo
                          l\release;D:\texlive\2020\bin\win32;C:\Users\miaoc\AppData\Local\Micro
                          soft\WindowsApps;D:\Program Files (x86)\Microsoft VS
                          Code\bin;D:\Program Files
                          (x86)\Julia-1.6.3\bin;C:\Users\miaoc\AppData\Local\atom\bin
             PSMODULEPATH=C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\Windows
                          PowerShell\v1.0\Modules
         PYTHONIOENCODING=UTF-8
       REQUESTS_CA_BUNDLE=<not set>
            SSL_CERT_FILE=<not set>
    VBOX_MSI_INSTALL_PATH=D:\Program Files\Oracle\VirtualBox\

     active environment : base
    active env location : C:\Users\miaoc\.julia\conda\3
       user config file : C:\Users\miaoc\.condarc
 populated config files : 
          conda version : 4.10.3
    conda-build version : not installed
         python version : 3.9.5.final.0
       virtual packages : __win=0=0
                          __archspec=1=x86_64
       base environment : C:\Users\miaoc\.julia\conda\3  (writable)
      conda av data dir : C:\Users\miaoc\.julia\conda\3\etc\conda
  conda av metadata url : None
           channel URLs : https://repo.anaconda.com/pkgs/main/win-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/win-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://repo.anaconda.com/pkgs/msys2/win-64
                          https://repo.anaconda.com/pkgs/msys2/noarch
          package cache : C:\Users\miaoc\.julia\conda\3\pkgs
                          C:\Users\miaoc\.conda\pkgs
                          C:\Users\miaoc\AppData\Local\conda\conda\pkgs
       envs directories : C:\Users\miaoc\.julia\conda\3\envs
                          C:\Users\miaoc\.conda\envs
                          C:\Users\miaoc\AppData\Local\conda\conda\envs
               platform : win-64
             user-agent : conda/4.10.3 requests/2.25.1 CPython/3.9.5 Windows/10 Windows/10.0.19042
          administrator : False
             netrc file : None
           offline mode : False


An unexpected error has occurred. Conda has prepared the above report.

Upload did not complete.
┌ Info: Using the Python distribution in the Conda package by default.
└ To use a different Python version, set ENV["PYTHON"]="pythoncommand" and re-run Pkg.build("PyCall").
[ Info: Running `conda install -y numpy` in root environment
ERROR: LoadError: failed process: Process(setenv(`'C:\Users\miaoc\.julia\conda\3\Scripts\conda.exe' install -y numpy`,["PATH=C:\\Users\\miaoc\\.julia\\conda\\3\\Library\\bin;D:\\ProgramData\\Anaconda3;D:\\ProgramData\\Anaconda3\\Library\\mingw-w64\\bin;D:\\ProgramData\\Anaconda3\\Library\\usr\\bin;D:\\ProgramData\\Anaconda3\\Library\\bin;D:\\ProgramData\\Anaconda3\\Scripts;D:\\ProgramData\\Miniconda3;D:\\ProgramData\\Miniconda3\\Library\\mingw-w64\\bin;D:\\ProgramData\\Miniconda3\\Library\\usr\\bin;D:\\ProgramData\\Miniconda3\\Library\\bin;D:\\ProgramData\\Miniconda3\\Scripts;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\WINDOWS\\System32\\OpenSSH\\;D:\\Program Files\\Git\\cmd;C:\\Program Files\\Pandoc\\;D:\\Strawberry\\c\\bin;D:\\Strawberry\\perl\\site\\bin;D:\\Strawberry\\perl\\bin;C:\\Users\\miaoc\\AppData\\Local\\activestate\\cache\\bin;C:\\Users\\miaoc\\AppData\\Local\\ActiveState\\StateTool\\release;D:\\texlive\\2020\\bin\\win32;C:\\Users\\miaoc\\AppData\\Local\\Microsoft\\WindowsApps;D:\\Program Files (x86)\\Microsoft VS Code\\bin;D:\\Program Files (x86)\\Julia-1.6.3\\bin;C:\\Users\\miaoc\\AppData\\Local\\atom\\bin", "USERDOMAIN_ROAMINGPROFILE=DESKTOP-A0FB857", "HOMEPATH=\\Users\\miaoc", "PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC", "SESSIONNAME=Console", "SYSTEMROOT=C:\\WINDOWS", "APPDATA=C:\\Users\\miaoc\\AppData\\Roaming", "PSMODULEPATH=C:\\Program Files\\WindowsPowerShell\\Modules;C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\Modules", "COMMONPROGRAMW6432=C:\\Program Files\\Common Files", "PROGRAMDATA=C:\\ProgramData"  …  "PROGRAMFILES(X86)=C:\\Program Files (x86)", "PROGRAMFILES=C:\\Program Files", "JPY_PARENT_PID=2268", "LOGONSERVER=\\\\DESKTOP-A0FB857", "DRIVERDATA=C:\\Windows\\System32\\Drivers\\DriverData", "CONDA_PREFIX=C:\\Users\\miaoc\\.julia\\conda\\3", "JULIA_LOAD_PATH=@;C:\\Users\\miaoc\\AppData\\Local\\Temp\\jl_0iEtUu", "SYSTEMDRIVE=C:", "PROCESSOR_ARCHITECTURE=AMD64", "OPENBLAS_MAIN_FREE=1"]), ProcessExited(1)) [1]

Stacktrace:
 [1] pipeline_error
   @ .\process.jl:525 [inlined]
 [2] run(::Cmd; wait::Bool)
   @ Base .\process.jl:440
 [3] run
   @ .\process.jl:438 [inlined]
 [4] runconda(args::Cmd, env::String)
   @ Conda C:\Users\miaoc\.julia\packages\Conda\sNGum\src\Conda.jl:129
 [5] add(pkg::String, env::String; channel::String)
   @ Conda C:\Users\miaoc\.julia\packages\Conda\sNGum\src\Conda.jl:221
 [6] add (repeats 2 times)
   @ C:\Users\miaoc\.julia\packages\Conda\sNGum\src\Conda.jl:220 [inlined]
 [7] top-level scope
   @ C:\Users\miaoc\.julia\packages\PyCall\BD546\deps\build.jl:84
 [8] include(fname::String)
   @ Base.MainInclude .\client.jl:444
 [9] top-level scope
   @ none:5
in expression starting at C:\Users\miaoc\.julia\packages\PyCall\BD546\deps\build.jl:43

Full log at C:\Users\miaoc\.julia\scratchspaces\44cfe95a-1eb2-52ea-b672-e2afdf69b78f\169bb8ea6b1b143c5cf57df6d34d022a7b60c6db\build.log

Stacktrace:
  [1] pkgerror(msg::String)
    @ Pkg.Types C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\Types.jl:55
  [2] (::Pkg.Operations.var"#82#87"{Bool, Pkg.Types.Context, String, Pkg.Types.PackageSpec})()
    @ Pkg.Operations C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\Operations.jl:1048
  [3] withenv(::Pkg.Operations.var"#82#87"{Bool, Pkg.Types.Context, String, Pkg.Types.PackageSpec}, ::Pair{String, String}, ::Vararg{Pair{String, B} where B, N} where N)
    @ Base .\env.jl:161
  [4] (::Pkg.Operations.var"#109#113"{String, Pkg.Operations.var"#82#87"{Bool, Pkg.Types.Context, String, Pkg.Types.PackageSpec}, Pkg.Types.PackageSpec})()
    @ Pkg.Operations C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\Operations.jl:1546
  [5] with_temp_env(fn::Pkg.Operations.var"#109#113"{String, Pkg.Operations.var"#82#87"{Bool, Pkg.Types.Context, String, Pkg.Types.PackageSpec}, Pkg.Types.PackageSpec}, temp_env::String)
    @ Pkg.Operations C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\Operations.jl:1448
  [6] (::Pkg.Operations.var"#108#112"{Pkg.Operations.var"#82#87"{Bool, Pkg.Types.Context, String, Pkg.Types.PackageSpec}, Pkg.Types.Context, Pkg.Types.PackageSpec, String, Pkg.Types.Project, String})(tmp::String)
    @ Pkg.Operations C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\Operations.jl:1521
  [7] mktempdir(fn::Pkg.Operations.var"#108#112"{Pkg.Operations.var"#82#87"{Bool, Pkg.Types.Context, String, Pkg.Types.PackageSpec}, Pkg.Types.Context, Pkg.Types.PackageSpec, String, Pkg.Types.Project, String}, parent::String; prefix::String)
    @ Base.Filesystem .\file.jl:729
  [8] mktempdir(fn::Function, parent::String) (repeats 2 times)
    @ Base.Filesystem .\file.jl:727
  [9] sandbox(fn::Function, ctx::Pkg.Types.Context, target::Pkg.Types.PackageSpec, target_path::String, sandbox_path::String, sandbox_project_override::Pkg.Types.Project)
    @ Pkg.Operations C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\Operations.jl:1487
 [10] build_versions(ctx::Pkg.Types.Context, uuids::Vector{Base.UUID}; verbose::Bool)
    @ Pkg.Operations C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\Operations.jl:1029
 [11] build(ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec}, verbose::Bool)
    @ Pkg.Operations C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\Operations.jl:910
 [12] build(ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec}; verbose::Bool, kwargs::Base.Iterators.Pairs{Symbol, IJulia.IJuliaStdio{Base.PipeEndpoint}, Tuple{Symbol}, NamedTuple{(:io,), Tuple{IJulia.IJuliaStdio{Base.PipeEndpoint}}}})
    @ Pkg.API C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\API.jl:900
 [13] build(pkgs::Vector{Pkg.Types.PackageSpec}; io::IJulia.IJuliaStdio{Base.PipeEndpoint}, kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Pkg.API C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\API.jl:80
 [14] build(pkgs::Vector{Pkg.Types.PackageSpec})
    @ Pkg.API C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\API.jl:78
 [15] #build#71
    @ C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\API.jl:76 [inlined]
 [16] build
    @ C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\API.jl:76 [inlined]
 [17] #build#70
    @ C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\API.jl:75 [inlined]
 [18] build(pkg::String)
    @ Pkg.API C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\API.jl:75
 [19] top-level scope
    @ In[7]:1
 [20] eval
    @ .\boot.jl:360 [inlined]
 [21] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
    @ Base .\loading.jl:1116

My package status is:

Pkg.status()
      Status `C:\Users\miaoc\.julia\environments\v1.6\Project.toml`
  [c52e3926] Atom v0.12.35
  [6e4b80f9] BenchmarkTools v1.2.0
  [336ed68f] CSV v0.9.6
  [a93c6f00] DataFrames v1.2.2
  [0c46a032] DifferentialEquations v6.19.0
  [89b67f3b] ExcelFiles v1.0.0
  [7073ff75] IJulia v1.23.2
  [e5e0dc1b] Juno v0.8.4
  [b98c9c47] Pipe v1.3.0
  [91a5bcdd] Plots v1.22.6
  [438e738f] PyCall v1.92.3
  [fdbf4ff8] XLSX v0.7.8
VERSION
v"1.6.3"

Any suggestion would be greatly appreciated!

Thank you,
Miao

This looks more like an problem installing numpy to me? But AFAIU PyCall could depend on numpy, so maybe a workaround could be to install numpy manually first?

Conda.jl (which PyCall uses under the hood) by default isolates itself from the system python & conda, precisely to prevent having to rely on the system state (though this can be enabled explicitly if so desired).

The problem in the OP reads more like a TLS failure to me (note the SSL errors). @caimiao0714, are you behind a corporate proxy or similar?

3 Likes

I had the same issue and the problem was caused by restrictions imposed in my OS (Windows 10) manage by my company. I solve the problem by moving the default location of the “.julia” directory (~\User.julia) to a location where I have full control. This is done by setting the environment variable JULIA_DEPOT_PATH=‘my\alternative\location’. Then open julia and you should be able to add PyCall