Live coding 2

I’m not on the paperspace yet. Was talking about on Ubuntu on our machine here. You know, where we do the setup on Ubuntu.

Got it. If you’ve got git installed, then it must have come with your distro. I don’t know which distros / version include it and which don’t.

1 Like

Thank you so much. Much appreciated.

Hi Jeremy,

Hope you are well.

Love the walk-thrus! It is so appreciated - :slight_smile:
I’m just wondering though, till when will be the walk-thrus please? I know its usually live from Tuesday (except tomorrow, as you had announced due to the next lesson in class tomorrow) to Friday. I’m still catching up, so just curious. :slight_smile:

Also, I wanted to humbly ask please: would it still be fine for us to post here after the last lesson ends next week Tuesday? Its my first time joining the fasti.ai live classes - really happy and appreciate everything, and really happy to be part of this wonderful community!

Thank you very much for everything, Jeremy. Really appreciate everything, so far!

No idea! Until we run out of things to talk about, I guess…

4 Likes

Not just fine – but highly recommended and appreciated!

2 Likes

Thank you - really appreciated a lot!

That’s really kind of you - soo appreciated!

This is how tmux shortcuts worked for me in WSL Ubuntu running inside Windows. After pressing "ctrl + b", then I had to release and press the next key combination.

See this issue here: Tmux Does not Work

That’s how it works on all platforms - not just WSL.

I got confused about whether all keys should be pressed together. Hence, I was not able to split the panes. Now it’s working fine for me. Thanks.

1 Like

Issue: How to open python 3 in tmux as it’s opens python 2.7

I’ve installed on my Mac the following:

  • Mamba
  • Homebrew
  • Tmux

When typing inside tmux “which python” I get “/usr/bin/python” but when I’m in Iterm/Terminal I get “/Users/my.user/mambaforge/bin/python”

Inside tmux I see that mamba is active as it adds “(base)” in front of my user

1 Like

I have this same issue.
Before starting tmux, which python points to mambaforge python
Screenshot 2022-08-13 at 5.32.30 AM

After running ‘tmux’, which python points to system python
Screenshot 2022-08-13 at 5.33.04 AM

TLDR; Here is the solution I found that will get back to mambaforge python while in tmux:

  • conda deactivate to turn off the base environment
  • source .bashrc to activate the mambaforge python
    Before trying the above, make sure you have the shell script that mambaforge use to activate the environment in .bashrc. For example if you have been following walkthrough 1 while using zsh shell, your shell script might be on .zshrc. If so, copy content from .zshrc to .bashrc

I believe the cause of the issue is that on Mac tmux starts a bash login shell instead of a bash non-login shell. Per this link, the difference between the two is :

  • bash login shell reads and executes commands from /etc/bash.bashrc and ~/.bashrc
  • bash non-login shell first read and execute from /etc/profile. After that it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile

At first I thought I just need to add the mambaforge shell script to .bash_profile and that would be a more elegant solution than the above fix. But it doesn’t work for me. Some command in my /etc/profile caused which python to still point to system python even after the mamba script is run.

This is the content of my /etc/profile

# System-wide .profile for sh(1)

if [ -x /usr/libexec/path_helper ]; then
        eval `/usr/libexec/path_helper -s`
fi

if [ "${BASH-no}" != "no" ]; then
        [ -r /etc/bashrc ] && . /etc/bashrc
fi

If I comment out the content of /etc/profile while having the mambascript in .bash_profile then starting tmux, which python points to mambaforce python as expected. But commenting out /etc/profile doesn’t feel safe so I don’t think that’s a solution.

It would be great if @jeremy or someone can help explain what in /etc/profile that cause this behavior, or a more elegant solution for solving this issue with using tmux on Mac.

Summary of what you need to install in Mac : (This is not summary of video):
Create a folder for git repository

Create repo in github

A- public

B- git ignore : put python

C- license : Apache 2.0 so other people can use your code

Do stuff in public

Make a git folder in your home directory :

mkdir git

Go inside directory :

cd git

Clone your repository here :

git clone git@github.com:bahmanapl/walkthru2.git

You can not do this using ssh cause you need a private and public key:

Type this on terminal and enter few times :

ssh-keygen

Type this on terminal create public key :

cat ~/.ssh/id_rsa.pub

Copy the public key to your github , where ?

Upper right corner click on your profile pic ->setting ->SSH and GPG keys → top right click on new SSH key button (the color is green)

Github ask you to log in, put password

How to run tmux in terminal :

First install it in Mac :

brew install tmux

Then type this to run tmux in terminal :

tmux

Now let`s get fastbook to do experimentation later in our local machine.

First we need to go to fastbook repo : GitHub - fastai/fastbook: The fastai book, published as Jupyter Notebooks

Then fork it , top right of your github , it should be around 5.9k forks from this repo.

Then you can use SSH to clone the book in your local repo , inside git folder in terminal type :(get SSH address from your fastbook repo):

git clone git@github.com:bahmanapl/fastbook.git

Then install fastai using this command in your git folder :

mamba install -c fastchan fastai

Then you need to install fastbook , type this in terminal:

mamba install -c fastchan fastbook

Last step you need to install sentencepeiece in terminal:

mamba install -c fastchan sentencepeiece

1 Like

I don’t have a Mac, so just some general comments while waiting for other answers.

I think you’ve got those reversed. As I understand it…

  • login shell ==> “profile”
  • non-login shell ==> “rc” (remote control)

I believe the cause of the issue is that on Mac tmux starts a bash login shell
instead of a bash non-login shell .

Mac tmux behaves the same as other platforms. On WSL, when I append echo IN PROFILE to /etc/profile this text displays when I start tmux. Without reference to a playform, here it says "Tmux uses a login shell by default. Hence, shells started by tmux skip ~/.bashrc ". That article provides a few suggestions to try.

It would be great if @jeremy or someone can help explain what in /etc/profile that cause this behavior,

You should be able to determine this by commenting out different lines from /etc/profile, even if it takes a few iteractions.

p.s. Please don’t @mention Jeremy and other admins unless something is burning.

2 Likes

Thanks for the pointers! I tried changing the content of /etc/profile/, turns out it’s the first block that call eval usr/libexec/path_helper -s that causes this behavior.

According to this link, usr/libexec/path_helper is a file that constructs PATH and MANPATH environment. path_helper reads its initial value from /etc/paths, and hence PATH initial value is

/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin

With the default content of /etc/profile, new paths is appended to the initial value of PATH as shown above. This explains while when tmux started, (base) environment was activated (meaning the mambaforge script did run) but which python still points to system python (as /usr/bin appears first in the PATH string).

The fix I’m looking for to make tmux behave as per the demo when using Mac is just adding PATH=“” in /etc/profile to reset the PATH variable before running eval

new content of /etc/profile

# System-wide .profile for sh(1)

if [ -x /usr/libexec/path_helper ]; then
        PATH=""
        eval `/usr/libexec/path_helper -s`
fi

if [ "${BASH-no}" != "no" ]; then
        [ -r /etc/bashrc ] && . /etc/bashrc
fi
1 Like

Hey guys!
I’m trying to use DuckDuckGo for images searching at 2nd notebook
and every time I’m running search_images_ddg it fails with Timeout exception
I’ve tried both Paperspace and local test (from laptop).
What can I do here?

This is search_images worked fine for me:(10-14 days ago)
from fastcore.all import *
import time

def search_images(term, max_images=200):
url = ‘DuckDuckGo
res = urlread(url,data={‘q’:term})
searchObj = re.search(r’vqd=([\d-]+)&‘, res)
requestUrl = url + ‘i.js’
params = dict(l=‘us-en’, o=‘json’, q=term, vqd=searchObj.group(1), f=’,', p=‘1’, v7exp=‘a’)
urls,data = set(),{‘next’:1}
while len(urls)<max_images and ‘next’ in data:
data = urljson(requestUrl,data=params)
urls.update(L(data[‘results’]).itemgot(‘image’))
requestUrl = url + data[‘next’]
time.sleep(0.2)
return L(urls)[:max_images]

This is also for downloading images :
if not path.exists():
path.mkdir()
for o in labequip_types:
dest = (path/o)
dest.mkdir(exist_ok=True,parents=True)
download_images(dest, urls=search_images(f’{o} photo’))

Do not forget to indent properly.

thanks a lot, I will try to use it

Well, as expected, it looks like a problem with Paperspace. Seems connection to DuckDuckGo is forbidden for some reason :frowning: