I activate some package so I can add dependencies:
(v1.0) pkg> activate Example
Activating environment at `~/Example/Project.toml`
(Example) pkg> add Unicode
Resolving package versions...
Updating `~/Example/Project.toml`
[4ec0a83e] + Unicode
Updating `~/Example/Manifest.toml`
[4ec0a83e] + Unicode
Now I want to go back to the default environment. I tried the following:
(v1.0) pkg> activate v1.0
Activating new environment at `~/v1.0/Project.toml`
But this does not seem correct because the environment is empty. How can I activate the default environment in Julia?
To go back to the default environment, use activate with no arguments:
(Example) pkg> activate
Activating environment at `~/.julia/environments/v1.2/Project.toml`
pkg> activate v1.0 is not correct because v1.0 is interpreted as the name of a directory in the current working directory.
You can learn more about activate with the built in help command:
pkg> help activate
Related
I am getting an error when I try to add a package in Julia. It is saying the package I am trying to add has "no known versions!". What can I do to resolve this?
This is a common issue when you lose connection to the Julia Registry (which is where packages are pulled from). You can first type ] to enter pkg mode in the Julia Repl and then do the following:
(#v1.5) pkg> registry remove General
Removing registry `General` from ~/.julia/registries/General
(#v1.5) pkg> registry add https://github.com/JuliaRegistries/General.git
Cloning registry from "https://github.com/JuliaRegistries/General.git"
Added registry `General` to `~/.julia/registries/General`
Try to add the Package again and the issue should be resolved.
Whenever I try to open up a Jupyter notebook via Anaconda, I do not have a "Julia" code option. I have tried using Pkg., uninstalling Julia and Anaconda but my Mac does not seem to be connecting the two. I have also tried to open a Jupyter notebook directly from the Julia Kernel and that still is not working! I'm not sure what the issue is or what I should do next, here is the error:
(#v1.5) pkg> add "IJulia"
Updating registry at `~/.julia/registries/General`
######################################################################## 100.0%
Resolving package versions...
No Changes to `~/.julia/environments/v1.5/Project.toml`
No Changes to `~/.julia/environments/v1.5/Manifest.toml`
The output you showed is not an error. It is saying that IJulia is already installed in your system.
You need to run the notebook method from IJulia package.
Do:
julia> Using IJulia
julia> notebook()
If you don't have juypter already installed it prompt asking if you want to install it simply press y and it will start it in your browser automatically.
Also if for any reason it didn't open it automatically you can open it yourself.
Type localhost:8888(or you can click the link) in your browser url bar to open it.
What you posted does not indicate an error, it merely says that IJulia is already installed in your default environment: no changes were needed to add it.
You next step should now be to run:
julia> using IJulia
julia> IJulia.notebook()
After this, a new notebook should open in your browser.
I ever had an issue like this also. To solve this you need to rebuild the IJulia by run like below:
Using Pkg
Pkg.add("IJulia")
Pkg.build("IJulia")
When I try to install IJulia from Julia terminal using the following commands:
using Pkg
Pkg.add("IJulia")
I get the following error:
SystemError: opening file "C:\\Users\\lenovo\\.julia\\registries\\General\\Registry.toml": No such file or directory
How may I fix this?
You can try removing the registry by doing: registry rm General and then try running: registry add https://github.com/JuliaRegistries/General in the Package Manager which can be accessed by entering ] into the repl.
See the Registry docs for reference: https://julialang.github.io/Pkg.jl/v1/registries/#Adding-registries-1
I am trying to download and install dependencies for a Julia project that's not in the package registry. It has a manifest and project file. How do I get all of the packages it depends on to download at once using the Julia Package manager?
Download the source: git clone https://github.com/RandomUser/Unregistered.jl
Activate the project: pkg> activate Unregistered.jl
Ensure any dependencies are installed: pkg> instantiate
Once the package is set up, you can use the package normally.
You can load the package:
julia> using Unregistered
Or even run its test suite:
pkg> test
FWIW, here is a "pure" Julia version of what #David Varela suggested.
After substituting <url-to-project> and /some/local/path this "just works" in the REPL or similar:
using Pkg
Pkg.GitTools.clone("<url-to-project>", "/some/local/path")
cd("/some/local/path")
Pkg.activate(".")
Pkg.instantiate()
# Pkg.precompile() # optional
Preparation (optional):
Create a new folder somewhere and cd into it.
Start Julia with julia --project=.
Now the actual downloading/installing:
Develop the project locally: pkg> dev --local https://github.com/RandomUser/Unregistered.jl
This will clone the unregistered project into a local subfolder dev/Unregistered and will install all the required dependencies.
If the unregistered project is a Julia package, you can now simply using Unregistered. If you want to work on Unregistered.jl itself you can pkg> activate dev/Unregistered to work in the project environment.
I want to use a package I found online, but I get the following error:
(Example) pkg> add Unregistered
Updating registry at `~/.julia/registries/General`
Updating git-repo `https://github.com/JuliaRegistries/General.git`
ERROR: The following package names could not be resolved:
* Unregistered (not found in project, manifest or registry)
Please specify by known `name=uuid`.
I have seen others use the add command, but it does not seem to work in this case.
To add an unregistered package, refer to it by URL:
(Example) pkg> add https://github.com/00vareladavid/Unregistered.jl
Updating git-repo `https://github.com/00vareladavid/Unregistered.jl`
Updating git-repo `https://github.com/00vareladavid/Unregistered.jl`
Resolving package versions...
Updating `~/.julia/environments/Example/Project.toml`
[dcb67f36] + Unregistered v0.2.0 #master (https://github.com/00vareladavid/Unregistered.jl)
Updating `~/.julia/environments/Example/Manifest.toml`
[7876af07] + Example v0.5.3
[dcb67f36] + Unregistered v0.2.0 #master (https://github.com/00vareladavid/Unregistered.jl)
Pkg will automatically install its dependencies.
After you have added the package, you can use it normally:
julia> import Unregistered
[ Info: Precompiling Unregistered [dcb67f36-efa0-11e8-0cef-2fc465ed98ae]
Note: Packages must have a toplevel Project.toml file with name, UUID, and version fields.