Cannot install the "ipywidgets" Jupyter Lab Extension on AWS sagemaker - bash

To install Jupyter Lab Extension on AWS sagemaker, You need to follow https://github.com/aws-samples/amazon-sagemaker-notebook-instance-lifecycle-config-samples/tree/master/scripts. And then create the lifecycle configuration accordingly.
I did it and this is my on-start.sh file.
#!/bin/bash
set -e
# OVERVIEW
# This script installs a jupyterlab extension package in SageMaker Notebook Instance
sudo -u ec2-user -i <<'EOF'
# PARAMETERS
EXTENSION_NAME=#jupyter-widgets/jupyterlab-manager
source /home/ec2-user/anaconda3/bin/activate JupyterSystemEnv
jupyter labextension install $EXTENSION_NAME
source /home/ec2-user/anaconda3/bin/deactivate
EOF
Everything should went smooth except for this extension it raises an error.
This is the error log from cloud watch.
/bin/bash: /tmp/OnStart_2019-06-26-23-3260vo0j6p: /bin/bash^M: bad interpreter: No such file or directory
This one is the error message shown in the sagemaker console.
Failure reason
Notebook Instance Lifecycle Config 'arn:aws:sagemaker:ap-southeast-1:658055165324:notebook-instance-lifecycle-config/jupyter-widgets-for-jupyterlab-copy' for Notebook Instance 'arn:aws:sagemaker:ap-southeast-1:658055165324:notebook-instance/test' took longer than 5 minutes. Please check your CloudWatch logs for more details if your Notebook Instance has Internet access.
I had done several attempts to locate the bug in the script file and the setup file of ipywidgets concerning the 'bad interpreter' error. I cannot find any traces of error in both.
I tried to upgrade my instance to T2 largest instance just in case the error came from the timeout.
The weirdest thing is that I am able to install it via the terminal from the terminal on jupyterlab. I measured the total time it takes to install and found it is around 4 mins just enough time(AWS should allow more time since this is only one extension install). Noted that this installation was performed under the T2 medium instance(the cheapest instance type you could get). If you install it this way to have to reboot the jupyter lab to make it work, then you reboot your instance and everything reverts back to the not-yet-install state. This suggests that there is no way to install jupyter lab extension rather than using the lifecycle cycle configurations which will lead you back to the error.
At this point, I gave up and use the jupyter notebook instead if I really want to use the ipywidgets.
Normally, this should be raised as technical support on AWS, but I have the basic plan so I decided to file it in StackOverflow for others that might encounter the same thing.

copy to notepad++
view>show symbol>show all symbols
replace "/r" with nothing
CRLF should become LF which is valid in unix
copy and paste as plain text!!!

Related

Jupyter Lab shows last used folder as the root directory when run from terminal (can't go up), but it's ok when run from Anaconda

I've been using Anaconda and Jupyter Lab & Notebook for a couple of months. I have 4 environments and had the usual problems I guess everyone has with package conflicts and such.
Today, when I was running a ipynb file in Jupyter Lab (run from Terminal), it got stuck when iterating over files and unzipping them, so I rebooted my Mac.
When I entered Jupyter Lab again, the folder it showed in the file browser was the last one I had used. It didn't have the option of going up, and if I entered a path in "open from path", it said that it couldn't find it. It's like the last folder I used is now considered the root path.
I tried running Jupyter Lab again from terminal, but same thing.
Of course, other environments weren't affected.
I thought it was a Jupyter Lab configuration problem, but when I run Jupyter Lab from Anaconda, it went back to working perfectly, so I'm wondering if there is a configuration setup specifically for Terminal.
I can work from Anaconda, and I can also reinstall the environment if needed, but I'd prefer to go back working the way I was.
Jupyter Notebook works fine.
Can anyone shed a light on what can be happening?
Thanks!
I tried:
reboot the computer
exit and reenter Jupyter Lab
go to "open from path"
search for jupyter config file with "jupyter --config-dir". Found "default-37a8.jupyterlab-workspace" in the /User/.jupyer/lab/workspaces folder, and it has the initial config for Jupyter Lab (directory, files opened), but it takes the info from when I close the instance I run from Anaconda. When run from terminal it's like it takes the initial config from somewhere else.

Why /user/local/go isn't recognized as a Go SDK in GoLand

I'm trying to setup GoLand to use WSL 2 as in this guide: https://www.jetbrains.com/help/go/how-to-use-wsl-development-environment-in-product.html
I've installed Go in the Ubuntu distro following the linux instructions on the GoLang website, and go version prints outs the version I downloaded, so it appears that Go is working inside WSL.
So now I tried to create a new project in GoLand, and I'm getting errors, which appear to come from the fact that the SDK isn't loaded in GoLand. The guide doesn't offer much guidance on this, so I just tried to add a local SDK.
When I select /usr/local/go I get an error that it's not a valid SDK.
So I created the ~/go directory, and then updated my .zshrc file to export the GOPATH and GOROOT environment variables, even though they already showed up when I ran go env, doing this got them to show up on a simple env call.
But I'm still getting the invalid SDK error like above.
Is there a configuration step I'm missing that isn't spelled out in the guide? I came across this old post about creating symlinks to fake the expected directory structure. I haven't done this because it's a really old post, has comments that say this has been fixed, and seems like a really odd solution.
Support for Go SDK in WSL2 will be available in the next 2021.3 release, please see GO-10618.
October 2021 update.
2021.3 reaches Early Access Program at the moment. GoLand suggests selecting Go SDK on WSL2 mount if the location of the project is on WSL2 as well.
I experienced this on my Debian machine and I wasn't using WSL2. I found that the actual cause of the issue is that Goland is unable to read the directory /usr/local/go/bin due to inadequate permission.
A possible solution is to run the goland.sh script as root. The script can be found in the bin/goland.sh directory of the Goland IDE folder. Here is a simple command to do run Goland as the root
export HISTIGNORE='*sudo -S*' && echo "sudo-password-here" | sudo -S /absolute-path-to-goland.sh
export HISTIGNORE='*sudo -S*' tells bash history to ignore caching any command matching sudo -S* to bash history. This way, your sudo-password isn't saved into the bash-history file.
echo "sudo-password-here" | pipes your sudo password as input to the next command.
sudo -S tells bash to read input for password prompt from stdin, which has been provided through the echo command.
Alternatively, you can just install the latest version of Goland. Hopefully, it doesn't come with this bug

Using AWS CLI with MobaXterm on Windows

I am a newbie to both AWS and MobaXterm. I am trying to use MobaXterm to manage AWS instances because it comes with bash.
I am following the commands as per https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-linux.html.
When I run the following command $ sudo ./aws/install, I get the following error:
Unable to start 'install': There is no application associated with the
given file name extension.
I did run chmod 777 to ensure that I am able to read/write/execute. Please see attached image.
I do know that I can use Windows CLI installer in command line. However, doing SSH to EC2 is a nightmare in Windows with all certificates. With MobaXterm (because of bash), it is very easy. So, my preference is to use MobaXterm instead of Windows command prompt.
Moreover, I don't want to directly install Ubuntu. Hence, I am looking for some guidance here. I'd appreciate any help.
I am hoping that I am not missing any package. Thanks for any help.
In order for AWS cli to run on MobaXterm, you will need to run the following commands in MobaXterm:
MobApt install python2-pip
pip2 install awscli
It will take some time for MobaXterm to complete steps 1 and 2. Also, AWS cli runs super slow in MobaXterm. You are better off using cmd.
This is the site that helped me ran AWS cli on MobaXterm.
https://majornetwork.net/2017/07/installing-aws-cli-on-cygwin/

"No such file or directory" for existing files in Amazon EC2 instance

I am getting a weird error of non-existent file in the Amazon EC2 instance, when logged in over ssh.
basically i have installed racket(mzscheme) from here, and it ran the install script perfectly, but after installation when i try to run the created binaries existing in "/home/ubuntu/racket/bin" then it says:
-bash: ./mzscheme: No such file or directory
basically for any binaries that i am trying to execute.
all the binaries have execute permission for all.
Tried rebooting the instance, with no fix.
$ which mzscheme
gives
/usr/local/bin/mzscheme
Thanks for helping.
EDIT
Here is a link i found, which talks about the same problem, but no solution,
on arc forums
The problem was the release mismatch. The Amazon EC2 instance was a 64-bit machine and i installed a 32-bit racket. As #ChrisJester-Young explained in the comments, mzscheme being a dynamic executable spits this rather confusing error message.

OSX Equivalent of WinSCP's Fully-Automated Local-Remote SFTP Sync?

I fondly remember working with WinSCP and using the fully automated local-to-remote syncing functionality, where the app would monitor a directory hierarchy and send changes to the remote server as they happened.
Is there an app available on OSX that accomplishes the same thing? I haven't really been able to find anything. When I do find something promising, it always turns out to be a traditional syncing app, where you need to initiate the sync command manually and it then scans the hierarchy to find changed files. That takes too long and isn't automated.
Been looking at the File System Events API, wondering if a small app could be pieced together with a small utility to trigger hierarchy changes and feed the changed directory to rsync or something.
Thanks for any leads!
There are two Mac-specific utilities you may be able to utilize to make your job easier:
Automator (link and link)
Folder Actions (link link and link)
Both tools have AppleScript as a common thread (which can be used to execute shell commands). You might be able to write a small AppleScript that is launched when a folder changes to call rsync and perform the service you require.
Well, I had the same kind of problem and it is possible using these together: rsync, SSH Passwordless Login, Watchdog (a Python sync utility) and Terminal Notifier (an OS X notification utility made with Ruby. Not needed, but helps to know when the sync has finished).
I created the key to Passwordless Login using this tutorial from Dreamhost wiki: http://cl.ly/MIw5
1.1. When you finish, test if everything is ok… if you can't Passwordless Login, maybe you have to try afp mount. Dreamhost (where my site is) does not allow afp mount, but allows Passwordless Login. In terminal, type:
ssh username#host.com
You should login without passwords being asked :P
I installed the Terminal Notifier from the Github page: http://cl.ly/MJ5x
2.1. I used the Gem installer command. In Terminal, type:
gem install terminal-notifier
2.3. Test if the notification works.In Terminal, type:
terminal-notifier -message "Starting sync"
Create a sh script to test the rsync + notification. Save it anywhere you like, with the name you like. In this example, I'll call it ~/Scripts/sync.sh I used the ".sh extension, but I don't know if its needed.
#!/bin/bash
terminal-notifier -message "Starting sync"
rsync -azP ~/Sites/folder/ user#host.com:site_folder/
terminal-notifier -message "Sync has finished"
3.1. Remember to give execution permission to this sh script. In Terminal, type:
sudo chmod 777 ~/Scripts/sync.sh
3.2. Run the script and verify if the messages are displayed correctly and the rsync actually sync your local folder with the remote folder.
Finally, I downloaded and installed Watchdog from the Github page: http://cl.ly/MJfb
4.1. First, I installed the libyaml dependency using Brew (there are lot's of help how to install Brew - like an "aptitude" for OS X). In Terminal, type:
brew install libyaml
4.2. Then, I used the "easy_install command". Go the folder of Watchdog, and type in Terminal:
easy_install watchdog
Now, everything is installed! Go the folder you want to be synced, change this code to your needs, and type in Terminal:
watchmedo shell-command
--patterns="*.php;*.txt;*.js;*.css" \
--recursive \
--command='~/Scripts/Sync.sh' \
.
It has to be EXACTLY this way, with the slashes and line breaks, so you'll have to copy these lines to a text editor, change the script, paste in terminal and press return.
I tried without the line breaks, and it doesn't work!
In my Mac, I always get an error, but it doesn't seem to affect anything:
/Library/Python/2.7/site-packages/argh-0.22.0-py2.7.egg/argh/completion.py:84: UserWarning: Bash completion not available. Install argcomplete.
Now, made some changes in a file inside the folder, and watch the magic!
I believe transmit does this.

Resources