Julialang tells ERROR: UndefVarError: Pkg not defined - julia

On a ubuntu 16.04,I downloaded julialang 1.0 binary package from
https://julialang.org/downloads/
,and extract it under:
/usr/local/julia
changed own and group to root,and added bin and lib to corresponded path:
#Julia
export JULIA_HOME=/usr/local/julia
export PATH=$JULIA_HOME/bin:$PATH
export LD_LIBRARY_PATH=$JULIA_HOME/lib:$LD_LIBRARY_PATH
then go to julia console to run:
Pkg.status()
got
ERROR: UndefVarError: Pkg not defined
anything I missed?

Pkg is no longer loaded by default, so it needs to be loaded:
julia> using Pkg

Related

Julia ArgumentError: Package RCall not found in current path:

I just opened a new Jupyter notebook, and want to load some libraries.
using LinearAlgebra
using SparseArrays
using Statistics
using StatsBase
using RCall
Everytime I run the cell, I keep on getting the same error:
ArgumentError: Package StatsBase not found in current path:
- Run `import Pkg; Pkg.add("StatsBase")` to install the StatsBase package.
So I run the suggested commands:
import Pkg; Pkg.add("StatsBase")
I rerun the top cell, and I get a new error:
ArgumentError: Package RCall not found in current path:
- Run `import Pkg; Pkg.add("RCall")` to install the RCall package.
What I don't get is why I get these error messages, as have installed these packages previously. If I open one of my pre-existing Jupyter notebooks, whis in a different directory, this error does not occur. However, if I run Julia in terminal I get the same error. Seemingly it is working in some directories, and not others.
What may be causing the problem?
Julia can have many virtual environments. The Julia virtual environment has its own package installation state, independent from the global environment.
Contrary to Python, each environment just keeps links to a package repository in local hard drive rather than contain full copies of each package.
The environment is defined in the Project.toml file.
Simply run Pkg.status() to check which environment you are working currently with (this time it shows my global environment):
julia> Pkg.status()
Status `C:\JuliaPkg\Julia-1.6.1\environments\v1.6\Project.toml`
[6e4b80f9] BenchmarkTools v1.1.0
[1e616198] COSMO v0.8.1
[336ed68f] CSV v0.8.5
...
For Jupyter notebooks those are defined in the Project.toml that is located at the same folder as your notebook. This is most likely the source of your problems and the reason why you observe "strange" package installation states.
The Procet.toml file is normally created when you activate a folder:
julia> using Pkg
julia> Pkg.activate(".")
Activating new environment at `C:\SomeMyFolder\Project.toml`
However, when you run Jupyter (e.g. notebook(dir=".")) Pkg.activate(".") happens automatically where a Project.toml file is found in the current folder.

How to load the PyPlot package in Julia-1.2.0-1

I cannot load the PyPlot package using Julia 1.2.0-1 running on MacOS 10.15.1.
After starting Julia I type a ] to get to "Pkg". I then type
add PyPlot
and get the following messages:
Updating registry at ~/.juliapro/JuliaPro_v1.2.01/registries/JuliaPro
Updating git-repo https://pkg.juliacomputing.com//registry/JuliaPro
ERROR: GitError(Code:EMERGECONFLICT, Class:Checkout, 1332 conflicts prevent checkout)
followed by a lengthy stacktrace. I have never seen this with previous Julia and MacOS versions; they just loaded the package.
Deleting the registry and restarting Julia did the trick! Thanks to all >who replied!

Fail to install RCall - Julia package

Following RCall's documentation, I ran Pkg.add("RCall") which looked to be working. Then, running using RCall gave:
WARNING: could not import StatsModels.Formula into RCall
ERROR: LoadError: RCall not properly installed. Please run Pkg.build("RCall")
#... few lines later
ERROR: Failed to precompile RCall [6f49c342-dc21-5d91-9882-a32aef131414] to C:\Users\jke4\.julia\compiled\v1.1\RCall\8GFyb.ji.
That's why I ran Pkg.build("RCall"):
┌ Error: Error building `RCall`:
│ ERROR: LoadError: R cannot be found. Set the "R_HOME" environment variable to re-run Pkg.build("RCall").
I believe, accordingly to RCall's documentation that I have to do a custom installation, but why can't am I able to simply install by Pkg.add("RCall") like it's suppose to be done?
RCall.jl can simply be installed with
Pkg.add("RCall")
Note:
Julia version is 1.1.0.
using Conda does work.
There is no R version installed in my Windows computer
I do understand what is my error message and how I can deal with it. My question is why do I have it whereas I wasn't suppose to, quoting RCall's documentation:
RCall.jl will automatically install R for you using Conda if it doesn't detect that you have R 3.4.0 or later installed already.
Update
Alright, I've done what #Cameron Bieganek suggests: pkg> pin StatsModels#0.5
And it seems to work for a moment. However, after doing ] up, accordingly with the issue I had in this question.
using RCall now gives:
ERROR: LoadError: RCall not properly installed. Please run Pkg.build("RCall")
and Pkg.build("RCall"):
┌ Error: Error building `RCall`:
│ ERROR: LoadError: IOError: stat: invalid argument (EINVAL)
This time I can't get what's the error.
GitHub
Please note that this question is also referenced on GitHub RCall.jl.

Installing XGBoost GPU for R on Ubuntu AMI

I'm on the AWS deeplearning Ubuntu AMI trying to install the XGboost GPU version R package using the instructions here: http://xgboost.readthedocs.io/en/latest/build.html#building-with-gpu-support
I've cloned the repo, made a new build dir and then executed:
cmake .. -DUSE_CUDA=ON -DR_LIB=ON
The error:
/usr/lib/R/bin/exec/R: symbol lookup error: /usr/lib/libblas.so.3: undefined symbol: gotoblas
/usr/lib/R/bin/exec/R: symbol lookup error: /usr/lib/libblas.so.3: undefined symbol: gotoblas
/usr/lib/R/bin/exec/R: symbol lookup error: /usr/lib/libblas.so.3: undefined symbol: gotoblas
CMake Error at /usr/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:148 (message):
Could NOT find LibR (missing: LIBR_HOME LIBR_INCLUDE_DIRS LIBR_LIB_DIR)
Call Stack (most recent call first):
/usr/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:388 (_FPHSA_FAILURE_MESSAGE)
cmake/modules/FindLibR.cmake:173 (find_package_handle_standard_args)
CMakeLists.txt:165 (find_package)
I believe this is due to the libblas.so.3 file living in /home/ubuntu/src/OpenBLAS instead of a more standard location. Just need a little nudge to bridge my lack of linux env variable knowledge and connect the two. Thanks!
You can try to create symbolic link from the expected location to the actual location of the shared library file or the directory which contains the expected shared library file to get around the problem.

Building error with IJulia

I used to use Julia in Jupyter notebook. I uninstalled yesterday the .julia directory because of other issues and after Pkg.add(IJulia) Im getting a building error related to ZMQ. the full error is below.
julia> Pkg.build("ZMQ")
INFO: Building Homebrew
Already up-to-date.
INFO: Building ZMQ
Warning: staticfloat/juliatranslated/zeromq32-3.2.5 already installed, it's just not linked.
Error: Formulae found in multiple taps:
* staticfloat/juliadeps/zeromq32
* staticfloat/juliatranslated/zeromq32
Please use the fully-qualified name e.g. staticfloat/juliadeps/zeromq32 to refer the formula.
=================================[ ERROR: ZMQ ]=================================
LoadError: failed process: Process(`/Users/pacagal/.julia/v0.5/Homebrew/deps/usr/bin/brew link staticfloat/juliatranslated/zeromq32 --force`, ProcessExited(1)) [1]
while loading /Users/pacagal/.julia/v0.5/ZMQ/deps/build.jl, in expression starting on line 35
================================================================================
================================[ BUILD ERRORS ]================================
WARNING: ZMQ had build errors.
- packages with build errors remain installed in /Users/pacagal/.julia/v0.5
- build the package(s) and all dependencies with `Pkg.build("ZMQ")`
- build a single package by running its `deps/build.jl` script
================================================================================
I have also run the build.jl file but I am getting an error too.
I was having the same issue this morning. In the terminal I ran brew install zmq and that resolved the issue.
I still had to run julia>Pkg.build("Nettle") after installing zmq and after that IJulia is running fine.

Resources