NameError: name 'Pkg' is not defined - julia

In the IJulia Notebook I'm trying to add the packages, but I'm getting the error:
NameError: name 'Pkg' is not defined

Python was wrongly selected instead of Julia in Jupyter:
Here's what happens in Julia:
And here's what happens in Python:

For me I had a very similar error, and apparently you have to define Pkg if you're installing this for the first time. Just enter
using Pkg
It looks like in your case the issue was you were using python but this is a fix for another case where you get this exact same error.

Related

How to manage Unfold precompiling error: _iszero not defined?

On a new computer I was trying to run Unfold and UnfoldMakie. See this error in both cases.
Like something wrong with the MutableArithmetics library.
Any idea how to manage it?
Also get this after update of MakieCore package:
Versions:
Julia 1.8.0.
Unfold v0.3.11
UnfoldMakie v0.1.4
It seems as a solution:
These packages work in the julia envv1.7, but do not work in v1.8.
In VScode you can change it here:
Finally figured out the problem:
First, I created a new environment/project.
https://pkgdocs.julialang.org/v1/environments/
Second, activated it in the notebook.
Third, installed problematic libraries through this code:
import Pkg
p = "Unfold"
Pkg.add(p)
Pkg.build(p)

XRJulia and findJulia in MacOSX

I'm having problem in MacOSX when trying to use XRJulia package.
When I run FindJulia, I get the error:
"Error in findJulia() :
No julia executable in search path and JULIA_BIN environment variable not set"
There seems to be an answer here but I don't really understand it,
How do I add a "key" in MacOSX and how do I add Julia to the path? A step by step explanation would be very much appreciated,
Thanks
EDIT: I resolved the problem and here is the piece of code I used for setup:
julia_setup(JULIA_HOME="/Applications/Julia-1.0.app/Contents/Resources/julia/bin")

Torch7 user-defined package not found

I am inside a directory structure where I have:
--train.lua
--utils
--sample.lua
train.lua has got an import line saying require('sample'), however when running the code Torch7 complains with the message
"module 'sample' not found:No LuaRocks module found for sample
I have tried changing instead to require('utils.sample'), but it still crashes. How to overcome this error?
I do not have the problem you described. Could you post the code in the files?
My three files:
main.lua
require 'utils.sample'
help()
utils/sample.lua
function help()
print("help")
end
I using th main.lua to run the code

kerasR giving error

I am trying to use kerasR for deep learning in R. I am trying to reproduce the examples in the package. Trying the following code produces error:
library(kerasR)
mod <- Sequential()
The error is:
Error in Sequential() : attempt to apply non-function
I'd suggest to look at this issue in KerasR Github repo:
https://github.com/statsmaths/kerasR/issues/1
Basically you should check where is located your version of python and then use reticulate::use_python("PATH_TO_PYTHON") to tell the system where to find Python.
Watch Out!
You can load just one Python interpreter per session and the use_python() function doesn't warn you if there already is a loaded interpreter.
Moreover if you run py_config() it automatically loads the first interpreter that he finds (which, in your case, seems to be the wrong one!), thus you'd better call reticulate::use_python("PATH_TO_PYTHON") before anything else.

ArgParse #add_arg_table not recognized in Julia

I'm using Julia v0.3.9 right now. I recently updated all my packages (I haven't opened Julia in a couple months), including ArgParse. The macro #add_arg_table isn't recognized though. In particular, I tried running example code here, but I get the following error:
ERROR: #add_arg_table not defined
in include at /Applications/Julia-0.3.9.app/Contents/Resources/julia/lib/julia/sys.dylib
in include_from_node1 at /Applications/Julia-0.3.9.app/Contents/Resources/julia/lib/julia/sys.dylib`
while loading /Users/Uthsav/Desktop/Walking The Interactome Work/arg.jl, in expression starting on line 42
This is essentially the problem I'm having in my own code. I looked but couldn't find any information about this besides what it says on the Github, which is that the macro #add_arg_table should still work. Any help would be greatly appreciated. Thanks a lot!

Resources