Changing jupyter kernels still falsely imports non-existing package - jupyter-notebook

I created a new conda environment myenv and the only package I installed is the uncommon package astropy.
I ran jupyter notebook out of this activated environment myenv, just to see that myenv isn't activated and I need the package nb_conda to activate it, which I then installed.
Now its possible for me to select and activate myenv and to import the aforesaid package. However, if I switch to any other environment ("Change kernel"), then the package astropy is still loaded, eventhough it is not installed.
Now Im thinking that the kernel wasn't switched afterall. But this also cannot be, since it's not possible for myenvto load any other package of another environment.
What am I missing?
Cheers
EDIT 1: I just noticed: whenever I run the aforesaid package in the base (?) environment Python3, then a hidden directory .astropy is created in my home path C:\Users\me\. In this hidden directory I can see two .cfg-files. Maybe this all has something to do with my question?
Why at all is this hidden directory created? Does every python package create such a hidden folder?

Related

R packages with Anaconda

I have Anaconda and I am learning to use it. I also installed R with it. It creates a separate enviroment " rstudio" with the default packages, but a lot of them appear with r-<name of the original package>, for example readxl is shown in the Anaconda enviroment as r-readxl. When I try to run in Rstudio, regardless of whether I type the original name of the package or the full "r-readxl" it does not find it. It says: there is no package called ‘r-readxl’.
Is there a way to tell Rsutdio that the packages in the Anaconda file are the ones of reference? How can I fix this?

Julia - Using development version of package in Jupyter Notebook

I'm working on a Package in Julia, and I created some functions and sent the pull request. I'm now waiting for it to be accepted in the master branch. In the mean time, I'd like to be able to use the package with the current functions I've just implemented in my Jupyter Notebook.
How can you use the development version of the package with your Jupyter Notebook?
Just tell Julia to use that package:
using Pkg
Pkg.develop(path=raw"C:\some_path\PackageName")
using PackageName
This will the package version from the given folder regardless of the current project settings.
When you want switch back to the main version:
Pkg.free(name="PackageName")
Note that this will work within a global package registry so this package version will be used across all Julia runs.
If you want to rather do it locally to the notebook just do
using Pkg, IJulia
notebook(dir=".") # select path to some empty directory
And then create a Jupyter notebook and type:
using Pkg
Pkg.activate(".")
Pkg.develop(path=raw"C:\some_path\PackageName")
This will create Project.toml file in the same directory where notebook is. When later opening the notebook just make sure Project.toml is in place - you will not need to call the command above again.

RStudio on Ubuntu server: Deploying library() as admin to load/attach package for all users

I'm trying to install and load/attach (the latter via library()) add-on packages in R as an admin in RStudio hosted on an Ubuntu server.
I've been able to install the packages just fine, so that the user at most has to run library(package_name) when using the package for the first time.
However, it seems that I should be able to deploy library() for a given package in the same way I do install.packages(), so that a user never needs to type library(package_name). Is this possible?
As an example, for the car package, I've done the following in the shell of RStudio as an admin:
sudo R
install.packages("car", lib="/usr/lib/R/site-library")
library(car, lib.loc="/usr/lib/R/site-library")
After doing this, the package car is indeed present in the desired location (/usr/lib/R/site-library), but I (and other users) still have to type library(car) before the package can be used. My third line of code (library(car,...)) obviously isn't correct. Is there some way to achieve this?

Installing R packages on Windows 7

On Windows 7 x64, I've got version 3.0.0 of R installed. Further, I've also set the environment variable R_LIBS_USER to point to a network drive. In rgui.exe, executing:
Sys.getenv("R_LIBS_USER")
outputs the same value that I previously set above. Also from R, installing packages into the personal library pointed to by R_LIBS_USER works fine. So far, so good.
With version 0.97.551 of RStudio installed, executing the same code above through RStudio also outputs the same value (as expected). However, from RStudio, my attempts at installing packages into the personal library fails. The error message effectively states that RStudio is unable to write to the personal library defined by R_LIBS_USER.
Before posting to stackoverflow, I checked the support forum for RStudio (http://support.rstudio.org/help/discussions/problems/4608-change-personal-library-for-installing-packages) where an admin states that the problem has to do with R and not RStudio. The admin goes on to reference the RStudio document generated by code
?.libPaths
in the RStudio IDE. The admin also provides additional guidance through link http://support.rstudio.org/help/kb/troubleshooting/getting-help-with-r.
After reviewing the IDE-generated document and forum link, I've determined that my environment is set up correctly. And yet, RStudio still fails.
Has anyone been able to get RStudio personal library working with a filesystem location other than the defaults?
I should clarify my needs a bit more. The environment to which this application will eventually be deployed prohibits normal users from running RStudio as administrators, hence the focus on R_LIBS_USER personal library. So although I know this would work, it is not a realistic option for me.
What I need is for RStudio to exclusively write to R_LIBS_USER and not attempt to also write to R_HOME (my assumption of what I think it is actually attempting to do.)
Add a line .libPaths("~/your-lib-path-here") to your .Rprofile and restart R. .libPaths() lets you write as well as read the the set of default libraries.
Alternately, if you can control the installation commands (i.e. you need your library to be available but it doesn't have to be the default), most R commands such as install.packages have a lib parameter that lets you manually specify the library to install to.
You might consider using an R package management system such as Packrat, which automates the job of installing your application's dependencies to a private library without you having to set it up manually. (Full disclosure, I'm a contributor to this package.) It works under RStudio.

R install package globally

How do I install an R package globally, so it's available to all users? Currently I'm doing
R.exe CMD INSTALL *.zip
But it does
* installing to library 'C:/Users/Matt/Documents/R/win-library/2.15'
I would like to install the packages alongside R in Windows' 'program files'.
Your big problem here is installing to C:\Program Files\. This means on versions of windows with file permissions, you need admin permissions to write to that folder. As R does not commonly request admin permissions, it will on default install to an user subdirectory, unless you run R as administrator (by right clicking on the shortcut). In which case you can use the GUI to install packages and it will install them globally by default. For working on the command line, you can also run the cmd session as administrator.
In future, it's recommended that you install R to say, C:\R\ to avoid this.
What worked for me was running:
install.packages("MyPackage", lib="C:\\Program Files\\R\\R-3.0.1\\library")
Installing it to Program Files wasn't a problem for me - the problem was that the default installation directory was in C:\\Users\\Mike\\Documents\\R\\...
Ultimately you just want to install it to wherever .libPaths() looks by default, and in my environment that was most commonly C:\\Program Files\\R\\R-3.0.1\\library
Here is a way to specify where to find or install libraries. You can put the libraries in a common directory.
http://cran.r-project.org/doc/manuals/R-admin.html#Managing-libraries

Resources