Adding new R packages to hosted Beaker Lab notebook - beaker-notebook

I'd like to use an R package that is not included in the default installation of the hosted version of Beaker, Beaker Lab. The code:
install.packages("raster")
fails with the message:
Error
Installing package into '/usr/local/lib/R/site-library'
Is there a way to install new libraries in Beaker Lab?

To install R packages:
1) Open scratch space, click BROWSE and create a directory rpackages
2) Create a blank R notebook
3) Type :
install.packages(‘packagename’, ‘/mnt/scratch/rpackages’, repos=’http://cran.us.r-project.org’)
and run the cell
4) Wait for installation to finish
5) If installation hangs for some time it means that something malfunctioned -> reload browser, close notebook, reopen notebook and redo the install command. This will continue from where it was before blocking.
To use installed packages:
In your R notebook, in the first cell (or cell before you use the package) type:
.libPaths(c(‘/mnt/scratch/rpackages’,.libPaths()))
And run the cell
Here's an example in Beaker Lab
https://lab.beakernotebook.com/approval/view/8645c600-3ec4-11e6-b811-8b63dac7dd4c

Related

FPC IDE: Can't find unit system

I just installed FPC 3.2.0 (on Linux Mint 19.3) and trying to use FPC IDE. I launched the IDE from the bin installation subfolder as ./fp, written a simplest program in IDE
program hello;
begin
writeln('hello');
end.
saved the program as hello.pas and when I compile it I get
(3,1) Fatal: Can't find unit system used by hello
(0) Fatal: Compilation aborted
This is strange because system is the compiler's unit, not a user's unit.
I tried to google the issue, found several posts in different forums, one question was dated back to 2007 year, and none of the questions was answered.
Is where a way to solve the issue or FPC IDE is dead for about 15 years?
Check the unit directories in options->directories -> unit directories.
The package configuration should have put a line like
/usr/lib/fpc/$FPCVERSION/units/$FPCTARGET/*
The dollar values are builtins (respectively 3.2.0 and i386-linux or x86_64-linux). Please verify that the directories with prebuilt .ppu .o are there.
Try to fix your installation of FPC or you can fix it manually by calling fpcmkcfg
fpcmkcfg -d "basepath=path/to/fpc/3.3" -o path/to/fpc.cfg
For instance, if the compiler is in /usr/local/bin, it will look in
/usr/local/etc.
Had the same problem on Ubuntu 20.04. To solve it, I had to create the file fp.cfg in my project's folder with the following content:
-Fu/usr/lib/x86_64-linux-gnu/fpc/$fpcversion/units/$fpctarget
-Fu/usr/lib/x86_64-linux-gnu/fpc/$fpcversion/units/$fpctarget/*
If this will not work, it means unit path on your system is different. You may use something like
dpkg -L fp-units-base-3.0.4 | grep .ppu
to find out where units are actually stored. Replace 3.0.4 with your actual Free Pascal version. If you do not know exact version, use
sudo apt install apt-show-versions
apt-show-versions fpc
It will show something like
fpc:all/focal 3.0.4+dfsg-23 uptodate
3.0.4 is the version number you need.
Another way of getting needed paths is running this command:
cat /etc/fpc.cfg | grep -- -Fu | head -2
So you may just run
cat /etc/fpc.cfg | grep -- -Fu | head -2 > fp.cfg
in your project's folder to have the problem solved.
How to use Free Pascal (Lazarus) on Linux - no install solution:
If not already installed, install "GNU binutils" (sudo apt-get install binutils)
Dowload the latest version of Free Pascal (Lazarus): from the Downloads section of the Lazarus Home page (Lazarus is a professional open-source cross platform IDE powered by Free Pascal):
2.1. In case of a Debian based Linux system (such as Ubuntu): the .deb package could be downloaded ("fpc-laz_<version> ... .deb" (replace <version> with an actual version number))
2.2. In case of a RPM based Linux system (such as Fedora): the .rpm package could be downloaded ("fpc-<version> ... .rpm" (replace <version> with an actual version number))
Extract the downloaded package:
3.1. Place the downloaded .deb / .rpm package in the folder where you are going to extract it
3.2. Extract the downloaded .deb / .rpm package by Right-Click-ing it and then choosing Extract Here
3.3. Rename the extracted folder, as you desire, for example "fpc"; Further we denote this folder as "<BASEFOLDER>" and its path as - "<BASEFOLDER_PATH>"
In the case of a .deb package: Open the extracted <BASEFOLDER> and then, extract "data.tar.xz" - by Right-Click-ing it and then choosing Extract Here
Launch the Free Pascal window by typing the next command in the terminal - this command may vary according to the terminal used - replace <terminal> with the terminal used (by default: for Gnome based Desktop Environments -> gnome-terminal; for KDE based Desktop Environments -> konsole; for Xfce based Desktop Environments -> xfce4-terminal; for the MATE Desktop Environment -> mate-terminal; ...):
<terminal> -e '<BASEFOLDER_PATH>/usr/bin/fp'
OR:
<terminal> -- '<BASEFOLDER_PATH>/usr/bin/fp'
To add the units folders: From the Free Pascal Menu, access: Options -> Directories -> and copy (CTRL + C to Copy from outside the IDE, and (FN + )SHIFT + Insert to Paste inside the IDE) to the "Units" tab, the next three lines, each on a new line (replace <BASEFOLDER_PATH> with its corresponding value, and replace <LIB_FOLDER> with: lib in case of a .deb package or lib64 in case of a .rpm package):
<BASEFOLDER_PATH>/usr/<LIB_FOLDER>/fpc/$fpcversion\units\$fpctarget
<BASEFOLDER_PATH>/usr/<LIB_FOLDER>/fpc/$fpcversion\units\$fpctarget\*
<BASEFOLDER_PATH>/usr/<LIB_FOLDER>/fpc/$fpcversion\units\$fpctarget\rtl
Please note that by moving the files from the <BASEFOLDER> directory to other <BASEFOLDER_PATH>, you'll have to update the above three lines so that they contain the new <BASEFOLDER_PATH>, otherwise you might get errors like:
"Fatal: Can't find unit ..."
For navigation inside the IDE using keyboard - the following shortcuts can be used: Alt + Highlighted-letter, Highlighted-letter(s), Tab / Shift + Tab, Arrows, Enter, Esc
For Official Online Documentation see:
Online Documentation

Tensorboard 2.2.1 Windows 10- No Dashboard Active for the Current Dataset

I have run a Keras code and generated log files for tensorboard. Tensorboard extension is not loading in Jupyter Notebook. Hence i tried to launch Tensorboard from the Command Prompt. But i always get the message that No dashboards are active for the current data set.
Here are my files generated
I ran the command
Error:
I tried couple of hacks from google but nothing worked.
EDIT1:
I installed protbuf using pip and was able to load tensorboard after i restarted my machine. However now i have another issue.
I defined Log Dir:
%load_ext tensorboard
This is creating the right log files and when i start the session in Jupyter it does not load the first time. If i run it again, it loads but says no dashboard available. If i restart my machine and launch tensorboard from Command Prompt again, this works for the same log directory

pyqtdeploy: Unable to detect MSVC2015 or MSVC2017

I'm trying pyqtdeploy for the first time, following the docs.
I'm getting the following error when running build-demo.py:
C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\Lib\site-packag
es\pyqtdeploy\demo>python build-demo.py
pyqtdeploy-sysroot: Unable to detect MSVC2015 or MSVC2017.
The py file seems to be getting Environment variables from the os module, as running the same command in python console it works fine. Somehow pyqtdeploy is having a problem with this.
I have the build tools installed in the system; what am I missing here?
You must search the location of the vcvars64.bat in your Build Tools' folder location and copy it. It depends on your system environment and the version of Visual Studio installed.
Before run pyqtdeploy script, paste that location in the command prompt. This will initialize the Environment and enable the detection of MSVC x64.
Step 1 : Download all the required packages ....
pic1
Step 2 : Browse to the directory where Micosoft Visual Studio is installed
pic2
Step 3: Search for vcvars64.bat in that directory
pic3
Step 4 : Run vcvars64.bat and if it successful, run pyqtdeploy-sysroot sysroot.json
pic4

Modify package identity in appx manifest after build

Summary: Is it possible to modify app package identity after compilation using makeappx.exe?
I have a windows store app (for LOB sideloading, not for the store), which I need to create multiple copies (variants/instances) of, because I need to be able to install and run multiple versions of the app at the same time as a single user. Say my app is called MyMultiInstanceApp, I want to clone it into two apps called MyMultiInstanceApp-Prod and MyMultiInstanceApp-Test, because having these, I can install and run the *-Prod app in version 1.0 and the *-Test app in version 1.1 simultaneously.
I can achieve this by making multiple builds in Visual Studio and changing the package identity (name) in the manifest before each build - as described in Locally deploy parallel versions of a Windows Store App.
However, I would like to do it after build time, by making the copies based on the initial .appx package and I have it almost working using makeappx.exe and signtool.exe, but after installing e.g. MyMultiInstanceApp-Test, the app hangs on startup.
My approach is the following:
1) Create the initial .appx file by building solution in VS or through msbuild
2) Unpack the appx using:
makeappx.exe unpack /p MyMultiInstanceApp.appx /d unpacked
3) Modify the package identity in AppxManifest.xml to be:
<Identity Name="MyMultiInstanceApp-Test" Publisher="CN=JohnDoe" Version="1.1.0.0" ProcessorArchitecture="neutral" />
<Properties>
<DisplayName>MyMultiInstanceApp-Test</DisplayName>
...
4) Re-package the app using:
makeappx.exe pack /d unpacked /p MyMultiInstanceApp-Test.appx
5) Sign the package using the same certificate as used for the initial package using:
signtool.exe sign /a /v /fd SHA256 /f MyCert.pfx MyMultiInstanceApp-Test.appx
Installation of the new MultiInstanceApp-Test.appx seems successful, but when trying to start it - it just hangs and the following is visible in the Event Viewer under the entry:
\Applications and Services Logs\Microsoft\Windows\Apps\Microsoft-Windows-TWinUI/Operational:
[INFORMATION] Activation of app MyMultiInstanceApp-Test_pf28w44wh44hy!App attempted.
Execution state: Attempted activation of the app, 0, The operation
completed successfully.
[ERROR] Activation of the app MyMultiInstanceApp-Test_pf28w44wh44hy!App for
the Windows.Launch contract failed with error: The remote procedure
call failed.
Am I missing something or is modification of package identity not possible after compilation?

adding RMySQL package to R fails (on Windows)?

I can't figure out why my RMySQL package won't install - here's what I get:
> install.packages('RMySQL',type='source')
trying URL 'http://cran.mirrors.hoobly.com/src/contrib/RMySQL_0.7-5.tar.gz'
Content type 'application/x-gzip' length 160769 bytes (157 Kb)
opened URL
downloaded 157 Kb
* installing *source* package 'RMySQL' ...
ERROR: configuration failed for package 'RMySQL'
* removing 'C:/PROGRA~1/R/R-212~1.0/library/RMySQL'
The downloaded packages are in '(foo)'
Warning message:
In install.packages("RMySQL", type = "source") : installation of package 'RMySQL' had non-zero exit status
I don't think it's a problem with the MySQL install, as the right values seem to be in the registry:
> Sys.getenv('MYSQL_HOME')
MYSQL_HOME "C:/PROGRA~1/MySQL/MYSQLS~1.1/"
> readRegistry("SOFTWARE\\MySQL AB", hive="HLM", maxdepth=2)
$`MySQL Server 5.1`
$`MySQL Server 5.1`$DataLocation
[1] "C:\\Documents and Settings\\All Users\\Application Data\\MySQL\\MySQL Server 5.1\\"
$`MySQL Server 5.1`$FoundExistingDataDir
[1] "0"
$`MySQL Server 5.1`$Location
[1] "C:\\Program Files\\MySQL\\MySQL Server 5.1\\"
$`MySQL Server 5.1`$Version
[1] "5.1.54"
Puzzled. Any help would be greatly appreciated!
The basic process is described here, but there are several hints, So I will describe the whole solution (please change the R version and paths if needed):
Install latest RTools from here
install MySQL or header and library files of mysql
create or edit file C:\Program Files\R\R-2.12.1\etc\Renviron.site and add line like MYSQL_HOME=C:/mysql (path to your mysql files)
copy libmysql.lib from mysql/lib to mysql/lib/opt to meet dependencies.
copy libmysql.dll to C:\Program Files\R\R-2.12.1\bin or to windows/system32 directory.
run install.packages('RMySQL',type='source') and wait while compilation will end.
This worked for me on Windows 7 64 bit, so there should be no problems with 32 bit versions
Initialy posted here (similar question).
First I would try following the directions on this page: http://biostat.mc.vanderbilt.edu/wiki/Main/RMySQL
Then, ensure that you actually have a MySQL client on your computer, not just the server itself. I've had a problem myself where I had to use an older binary for the client, but you can download these from mysql website.
I created a binary which might work for people:
http://kenahoo.blogspot.com/2011/09/rmysql-binary-for-windows-7.html
I basically followed all these directions, including the ones at the Vanderbilt page, but for one reason or another it doesn't always seem to work. Anyway, hope this might be helpful for people who have the same versions of stuff I used.
I was having this same problem on Windows 7 with R 2.12.1 x64 and resolved it by:
Changing the R directory in my PATH variable to C:\Program Files\R\R-2.12.1\bin\x64 (rather than just ...\R-2.12.1\bin).
Copying ...\MySQL Server 5.5\lib\libmysql.dll to ...\MySQL Server 5.5\bin\.
Running R CMD INSTALL RMySQL_0.7-5.tar.gz in cmd.exe (install.packages('RMySQL',type='source') in R still would not work).
I came across this step-by-step guide to install RMySQL under Windows7 64bit.
http://www.ahschulz.de/2013/07/23/installing-rmysql-under-windows/
The software I used are:
Windows 8 OS
R3.0.2 - 64bit
Rtools 3.1
MySQL Server Community Edition 5.6 - 64bit
Following the above guide (with screenshots provided), my installation and loading of the RMySQL package works.
Many thanks to Arne Hendrik Schulz!
As Marek said. There is no windows binary for this package. I had similar troubles on my Mac when I tried to install RPostgreSQL (because there's no binary for Mac) in the end I had to compile it on my own and modify several files.
For the MySQL part(if you don't know much about MySQL), you might want to use WAMP which is admittedly more than you need, but easy to install and to start and shut down.
For some compiling help you might be interested in Rtools
HTH
BTW: What kind of windows do you run (sry, if I missed it)
You however there is one additional requirement at present (with the MySQL server version 5.5 & R2.12.1) follow thehttp://biostat.mc.vanderbilt.edu/wiki/Main/RMySQL instructions at present as the locations of the libmySQL.dll differs to what is expected in the package.
i.e. for the 64bit compiling.
it expects the libmySQL.dll to be in "${MYSQL_HOME}"/bin/libmySQL.dll
so simply copy the dll over to the /bin dir and it will now compile.
for the 32bit compilling.
the libmySQL.lib is expected in "${MYSQL_HOME}"/lib/opt/libmysql.lib
again moving this should solve the problem.
Alternatively, if you don't want to or can't move these files. Then you can edit the source code files:
Makevars.win
Makevars.win32
Makevars.win64
appropriately pointing to /lib/libmysql.dll /lib/libmysql.lib
Add MySQL and RTools directory to the PATH!
Here is my PATH ; ~blah~;C:\Program Files\MySQL\MySQL Server 5.5\bin;c:\rtools\bin;C:\Rtools\gcc-4.6.3\bin;
I was working for last 2 days on Installation of R with RMySQL package, finally got the solution for that, here are the steps to install RMySQL package:-
DOWNLOAD SOFTWARE FROM THE FOLLOWING LINKS:
*a. R2.13.2: Download R from http://cran.stat.sfu.ca/index.html
b. RTools 214: Download RTools from http://cran.cict.fr
c. RMySQL 0.8-0.tar.gz: Download RMySQL from
http://biostat.mc.vanderbilt.edu/wiki/main/RMySQL/RMySQL_0.8-0.tar.gz
d. MySQL Server 5.0: download it from http://dev.mysql.com
e. RSTUDIO (optional): download it from http://rstudio.org*
SET THE FOLLOWING ENVIRONMENT VARIABLES
* a. MYSQL_HOME : <drive>/path to MySQL installation folder
e.g. MYSQL_HOME= C:\Program Files\MySQL\MySQL Server 5.5\
b. R_HOME: <drive>/path to R installation
e.g. R_HOME=C:\Program Files\R\R-2.13.2\
c. PATH: Modify path to accommodate the above variables. *
Be sure that the following paths areincluded in your Windows PATH variable:
\Rtools\2.14\bin
\Rtools\2.14\MinGW\bin
\Rtools\2.14\MinGW64\bin
CREATE FOLDER AND COPY FILES
a. OPT: Create a folder OPT under C:\Program Files\MySQL\MySQL Server 5.5\lib and copy
MYSQLLIB.LIB the above path. Also copy libmysql.dll to \\R\R-2.14.0\bin\ (64 bit) Or \\R\R-2.14.0\bin\i386\ (32 bit) and to C:\Windows\System32.
b. Renviron.site: create or edit a file \\R\R-2.14.0\etc\Renviron.site and add a
line: MYSQL_HOME =”C:/Program Files/MySQL/MySQL Server 5.5/”
NB: USE FORWARD SLASH AND DOUBLE QUOTES HERE
c. libMySQL.dll: Copy this file to C:\Program Files\R\R-2.13.2\bin\i386 as well as C:\Program
Files\R\R-2.13.2\bin
RUN COMMANDS
a. Install.Packages: Run R GUI by clicking on the R icon on desktop or from Start menu. Type
INSTALL.PACKAGES(“RMySQL”,type=”Sources”). This will download the required software from repositories.
b. Command Prompt: Copy the downloaded zip file (in step 4.a.) and paste it under R
installation folder. Go to start menu and open Command Prompt. Go to the R installation folder and type R CMD INSTALL RMySQL_0.8-0.tar.gz
*COMMANDS:
>library(RMySQL)
>drv = dbDriver("MySQL")
>con = dbConnect(drv,host="localhost",dbname="test",user="root",pass="root")
>album = dbGetQuery(con,statement="select * from t_master")
>album*
18 months later, new laptop, same problem. Returning to the scene of the crime - sorry January 2011 self; we're in the future, and this installation still isn't any fun.
Lessons learned:
-Updated RTools are essential. Get them.
-Are you seeing an error along the lines of .onLoad failed in loadNamespace() for 'RMySQL', details? This seems to mean that there's a problem with your system environment variables.
In R, run
Sys.getenv('MYSQL_HOME')
If it spits back a path like
[1] "C:\\Program Files\\MySQL\\MySQL Server 5.6"
you're good. But if it gives you empty string, you need to set this.
These are all Windows 7 directions, but the process is pretty similar in XP, if memory serves.
1) Bring up System Properties > Advanced > Environment Variables.
2) In the lower 'System Variables' pane, click 'New'.
3) Variable name is MYSQL_HOME and value is whatever the path is to your MySQL installation - mine was C:\Program Files\MySQL\MySQL Server 5.6
Newer versions of MySQL don't seem to create an environment variable on install - that and the lack of binaries for RMySQL explain why this questions has garnered 8,000 hits.
-Still stuck? Here are two additional in-depth writeups: 1, 2
Following worked for me in red hat linux
wget http://cran.r-project.org/src/contrib/RMySQL_0.9-3.tar.gz
sudo R CMD INSTALL --configure-args='--with-mysql-inc=/usr/include/mysql' --configure-args='--with-mysql-lib=/usr/lib64/mysql' RMySQL_0.9-3.tar.gz