【问题标题】:Using PyPlot in Julia gives Error: PyCall not properly installed在 Julia 中使用 PyPlot 会出现错误:PyCall 未正确安装
【发布时间】:2020-12-08 20:05:28
【问题描述】:

我是 Julia 的新手。我正在尝试使用

导入“PyPlot”
using PyPlot

但它总是返回以下错误:

[ Info: Precompiling PyPlot [d330b81b-6aea-500a-939a-2ce795aea3ee]
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 C:\Users\Carlos\.julia\packages\PyCall\BcTLp\src\startup
.jl:44
 [3] include(::Function, ::Module, ::String) at .\Base.jl:380
 [4] include at .\Base.jl:368 [inlined]
 [5] include(::String) at C:\Users\Carlos\.julia\packages\PyCall\BcTLp\src\PyCal
l.jl:1
 [6] top-level scope at C:\Users\Carlos\.julia\packages\PyCall\BcTLp\src\PyCall.
jl:38
 [7] include(::Function, ::Module, ::String) at .\Base.jl:380
 [8] include(::Module, ::String) at .\Base.jl:368
 [9] top-level scope at none:2
 [10] eval at .\boot.jl:331 [inlined]
 [11] eval(::Expr) at .\client.jl:467
 [12] top-level scope at .\none:3
in expression starting at C:\Users\Carlos\.julia\packages\PyCall\BcTLp\src\start
up.jl:41
in expression starting at C:\Users\Carlos\.julia\packages\PyCall\BcTLp\src\PyCal
l.jl:38
ERROR: LoadError: Failed to precompile PyCall [438e738f-606a-5dbb-bf0a-cddfbfd45
ab0] to C:\Users\Carlos\.julia\compiled\v1.5\PyCall\GkzkC_NvSXt.ji.
Stacktrace:
 [1] error(::String) at .\error.jl:33
 [2] compilecache(::Base.PkgId, ::String) at .\loading.jl:1290
 [3] _require(::Base.PkgId) at .\loading.jl:1030
 [4] require(::Base.PkgId) at .\loading.jl:928
 [5] require(::Module, ::Symbol) at .\loading.jl:923
 [6] include(::Function, ::Module, ::String) at .\Base.jl:380
 [7] include(::Module, ::String) at .\Base.jl:368
 [8] top-level scope at none:2
 [9] eval at .\boot.jl:331 [inlined]
 [10] eval(::Expr) at .\client.jl:467
 [11] top-level scope at .\none:3
in expression starting at C:\Users\Carlos\.julia\packages\PyPlot\XHEG0\src\PyPlo
t.jl:4
ERROR: Failed to precompile PyPlot [d330b81b-6aea-500a-939a-2ce795aea3ee] to C:\
Users\Carlos\.julia\compiled\v1.5\PyPlot\oatAj_NvSXt.ji.
Stacktrace:
 [1] error(::String) at .\error.jl:33
 [2] compilecache(::Base.PkgId, ::String) at .\loading.jl:1290
 [3] _require(::Base.PkgId) at .\loading.jl:1030
 [4] require(::Base.PkgId) at .\loading.jl:928
 [5] require(::Module, ::Symbol) at .\loading.jl:923

当我使用Pkg.build("PyCall") 时,我收到以下错误:

julia> Pkg.build("PyCall")
   Building Conda ─→ `C:\Users\Carlos\.julia\packages\Conda\x5ml4\deps\build.log
`
   Building PyCall → `C:\Users\Carlos\.julia\packages\PyCall\BcTLp\deps\build.lo
g`
┌ Error: Error building `PyCall`:
│ ┌ 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: Downloading miniconda installer ...
│ ERROR: LoadError: failed process: Process(`'C:\Windows\System32\WindowsPowerSh
ell\v1.0\powershell.exe' -Version 3 -NoProfile -Command "[System.Net.ServicePoin
tManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; (New-Obj
ect System.Net.Webclient).DownloadFile('https://repo.continuum.io/miniconda/Mini
conda3-latest-Windows-x86_64.exe', 'C:\Users\Carlos\.julia\conda\3\installer.exe
')"`, ProcessExited(3221225477)) [3221225477]
│
│ Stacktrace:
│  [1] pipeline_error at .\process.jl:525 [inlined]
│  [2] download_powershell(::String, ::String) at .\download.jl:20
│  [3] download at .\download.jl:64 [inlined]
│  [4] _install_conda(::String, ::Bool) at C:\Users\Carlos\.julia\packages\Conda
\x5ml4\src\Conda.jl:166
│  [5] _install_conda(::String) at C:\Users\Carlos\.julia\packages\Conda\x5ml4\s
rc\Conda.jl:157
│  [6] runconda(::Cmd, ::String) at C:\Users\Carlos\.julia\packages\Conda\x5ml4\
src\Conda.jl:114
│  [7] add(::String, ::String; channel::String) at C:\Users\Carlos\.julia\packag
es\Conda\x5ml4\src\Conda.jl:190
│  [8] add at C:\Users\Carlos\.julia\packages\Conda\x5ml4\src\Conda.jl:189 [inli
ned] (repeats 2 times)
│  [9] top-level scope at C:\Users\Carlos\.julia\packages\PyCall\BcTLp\deps\buil
d.jl:84
│  [10] include(::String) at .\client.jl:457
│  [11] top-level scope at none:5
│ in expression starting at C:\Users\Carlos\.julia\packages\PyCall\BcTLp\deps\bu
ild.jl:43
└ @ Pkg.Operations D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib
\v1.5\Pkg\src\Operations.jl:942

我尝试了几种不同的解决方案,这些解决方案在不同的论坛(包括 StackOverflow)中找到,但这些解决方案似乎不适用于我的具体情况。似乎与防病毒/防火墙问题无关。

另外,问题出在 PyCall 而不是 PyPlot 上。

有人知道在这里做什么吗?

谢谢。

【问题讨论】:

  • 当您按照错误消息中的第一个建议并运行Pkg.build("PyCall") 时会发生什么? (这也需要using Pkg)。
  • @Przemyslaw Szufel 完成。我用Pkg.build("PyCall") 的输出编辑了我的问题,这也给了我一个错误。

标签: python matplotlib error-handling package julia


【解决方案1】:

问题实际上发生在Conda.jl 中,PyCall 使用它来安装 Python 发行版。特别是,下载命令无法获取 miniconda 安装程序。你可以试试跑

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Version 3 -NoProfile -Command "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; (New-Object System.Net.Webclient).DownloadFile('https://repo.continuum.io/miniconda/Miniconda3-latest-Windows-x86_64.exe', 'C:\Users\Carlos\.julia\conda\3\installer.exe')"

在您的终端中手动查看是否可以重现该问题。 (如果下载失败,最常见的困难来源是防火墙。)

作为一种解决方法,您可以自己安装 Python+Matplotlib(例如下载并安装 Anaconda Python)和configure PyCall to use that,而不是安装自己的 Python 发行版。

【讨论】:

  • 错误 3221225477 是访问冲突错误。因此,这意味着 powershell.exe 非常难看。很难说有什么帮助 - 可能是文件系统、驱动程序的问题,或者 Windows 更新可能会有所帮助。
  • 莫非你没有C:\Users\Carlos\.julia\conda\3的写权限?
  • 这可能是问题所在,因为 Julia 1.5.3 在 WIndows 上存在权限错误(在某些情况下您需要手动设置权限)。但是据我所知,此错误与 RAM 访问错误有关。
猜你喜欢
  • 2015-01-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-12-15
  • 1970-01-01
  • 2017-07-25
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多