Difference between revisions of "Pi Setup Dec 2018 - Stretch"

From OpenCircuits
Jump to navigation Jump to search
 
(21 intermediate revisions by the same user not shown)
Line 15: Line 15:
  
 
= Setup =
 
= Setup =
 +
 +
at some point may want a flash drive instead of sd card
 +
*'''[https://www.stewright.me/2013/05/install-and-run-raspbian-from-a-usb-flash-drive/ Install & Run Raspbian from a USB Flash Drive - boost Performance ]'''
 +
 
next look at:
 
next look at:
  
Line 33: Line 37:
  
 
You many find the following of use as well [[Linux Commands On Pi]]
 
You many find the following of use as well [[Linux Commands On Pi]]
 +
 +
later you may use
 +
<pre>
 +
sudo apt-get clean
 +
</pre>
 +
 +
apt-get clean find software packages that are obsolete or not needed in your system and removes them. That results in a cleaner, more performant, and better system. That's good.
 +
 +
 +
And I found this as a complete update: '''[https://askubuntu.com/questions/196768/how-to-install-updates-via-command-line apt - How to install updates via command line? - Ask Ubuntu ]'''
 +
<pre>
 +
sudo apt-get update
 +
sudo apt-get upgrade -y
 +
sudo apt-get dist-upgrade -y
 +
sudo apt-get autoremove -y
 +
sudo apt-get autoclean -y
 +
</pre>
 +
 +
'''In any case when done reboot.'''
 +
 +
Lots of update links:
 +
 +
*'''[https://askubuntu.com/questions/196768/how-to-install-updates-via-command-line apt - How to install updates via command line? - Ask Ubuntu ]'''
 +
*'''[https://www.linux.com/learn/linux-101-updating-your-system Linux 101: Updating Your System | Linux.com | The source for Linux information ]'''
 +
*'''[https://learn.pimoroni.com/tutorial/raspberry-pi/keeping-your-raspberry-pi-updated Keeping your Raspberry Pi up-to-date - Pimoroni Yarr-niversity ]'''
 +
*'''[http://www.raspberry-projects.com/pi/command-line/update-packages Update Packages – Raspberry Pi Projects ]'''
 +
*'''[https://pimylifeup.com/update-raspbian/ How to Update Raspbian: All you need to know! - Pi My Life Up ]'''
  
 
= Remote Desktop VNC =
 
= Remote Desktop VNC =
  
* vnc
+
* vnc -- turn on use the preferences -- if we could ssh in perhaps we could set up never using a local display, keyboard .....
  
Default login. Username: pi. Password: raspberry. So, type pi, enter, raspberry, enter.
+
Default login. Username: pi. Password: raspberry. So, type pi, enter, raspberry, enter.  Unless you have changed it.
  
 +
From now on you can use the keyboard, mouse and screen of your pc.  You will need the vnc viewer and the tcpip address of your Pi.
  
 
== Static Ip Address ==
 
== Static Ip Address ==
Line 79: Line 111:
 
then sudo reboot to try it out -  ivp 6 may be a good addition to look into
 
then sudo reboot to try it out -  ivp 6 may be a good addition to look into
  
this does part of wifi, but need more
 
  
 
==== finish get wifi working ====
 
==== finish get wifi working ====
 +
 +
above does part of wifi, but need more -- which is to select wifi using the icon upper right of screen.  May be a config file way to do it but have not found a reference that seems accurate for this os.
  
 
= software installed with package manager =
 
= software installed with package manager =
Line 163: Line 196:
 
mount -a
 
mount -a
  
== Updating Python ==
+
== Updating Python3 ==
  
 
Spyder says:You have missing dependencies!
 
Spyder says:You have missing dependencies!
Line 177: Line 210:
 
sudo conda install pyperclip  -- conda not installed, on windows part of spyder, apparently not here
 
sudo conda install pyperclip  -- conda not installed, on windows part of spyder, apparently not here
  
ok
+
ok:
 
sudo pip install pyperclip
 
sudo pip install pyperclip
  
sudo pip install rope
+
ok:
 +
sudo pip3 install rope
 +
 
 +
           
 +
</pre>
 +
 
 +
 
 +
== Autostart ==
 +
 
 +
Update a file but which?  Various suggestions include
 +
 
 +
*sudo leafpad ~/.config/lxsession/LXDE/autostart  would be a new file on my system, this may be outdated
 +
 
 +
*sudo leafpad ~/.config/lxsession/LXDE-pi/autostart  does exist so I will try it.  -- and it worked  added "python3 /home/pi/autoexec.py"
 +
*
 +
* - by editing /etc/rc.local in my case the line added looks like this:  su - pi -c kodi  -- I have not tried this
 +
 
 +
since i cannot get fstab to work this is where I do my share
 +
 
 +
 
 +
 
 +
<pre>
 +
 
 
              
 
              
 
</pre>
 
</pre>
  
 +
= Clone a Copy for Further Use =
 +
 +
pi now has a utility for this that is supposed to even go from a large sd to a smaller one ( as long as the stuff fits )
 +
 +
 +
*'''[https://pishop.co.za/blog/my-tutorial-post/clone-your-micro-sd-directly-on-rpi/ Clone your micro SD directly on RPi – PiShop Blog ]'''
 +
 +
Some step by step:
 +
 +
* Identify the source os: '''[https://www.meccanismocomplesso.org/en/how-to-raspberry-checking-raspbian-version-update-upgrade/ How To for Raspberry – Checking the Raspbian version (update & upgrade) – Meccanismo Complesso ]'''
 +
there should be a file....
 +
 +
<pre>
 +
 +
 +
cat /etc/os-release
 +
  .... or ....
 +
uname -a
 +
  .... or ....
 +
 +
  .... or ....
 +
 +
 +
</pre>
 +
 +
 +
 +
 +
* Start with a Pi that you want to copy
 +
 +
* You will need a second sd card drive for the clone of the os, it will be wiped
 +
 +
* Bring the source up to date -- run the update steps above.
 +
 +
* Reboot
 +
* Identify the old dirve: f -Bm  will show it and its disk usage
 +
* Identify the new drive how? Plug in and it will ask to open a file manager that goes to the mounted card at: media/pi/xxxxxx
 +
 +
* Run utility. Menu -> Accessories -> SD Card Copier
 +
 +
* Put new os in a RPi ( can even use the one used for cloning )
 +
 +
* Fix the tcp ip address so it does not conflict.
 +
 +
= Get Python 3.6 =
 +
 +
* Why 3.6?  Well it is almost up to date, and I love f-strings  "print the str of an expression {some_expression}"  I do not want to program without it.
 +
 +
* Most methods I have tried are not very satisfactory.  Including building from source.  Problems include lack of software distribution command like pip to upgrade it.
 +
 +
* What did work?: berryconda which also gave me conda and pip useful install tools.  Link:  *'''[https://github.com/jjhelmus/berryconda jjhelmus/berryconda: Conda based Python distribution for the Raspberry Pi ]'''  After install pretty much typing '''python joe.py''' worked.  But in some cases it did not.  So in some files I used the command more explicitly: 
 +
 +
<pre>
 +
 +
# -------------- smart_terminal:run ------------
 +
 +
proc = Popen( [r"cd  /home/pi/SmartTerminal/; /home/pi/berryconda3/bin/python smart_terminal.py"], shell=True )
 +
 +
# -------------- smart_plug_graph:run ------------
 +
 +
proc = Popen( [r"cd /home/pi/smart_plug/  ; /home/pi/berryconda3/bin/python smart_plug_graph.py"], shell=True ) 
 +
 +
# -------------- smart_plug:run ------------
 +
 +
proc = Popen( [r"cd /home/pi/smart_plug/  ; /home/pi/berryconda3/bin/python smart_plug.py"], shell=True ) 
 +
 +
#proc = Popen( [ "leafpad /home/pi/smart_plug/smart_plug.py"], shell=True ) #
 +
 +
print( " autoexec.py all done " )
 +
 +
 +
</pre>
 +
 +
And conda  install ...... works.  I cannot remember if pip was in place, if not install with conda.  Then the conda and pip installs go into your 3.6 install.
 +
 +
= Change Terminal Colors =
  
 +
* Still need to figure this out, but default colors can be really hard to read over VNC viewer.
  
 +
* sudo leafpad  .bashrc
 +
* setvtrgb
  
  
 +
== Links ==
  
 +
 +
*'''[https://www.raspberrypi.org/forums/viewtopic.php?p=584429 Terminal COlor change - Raspberry Pi Forums ]'''
 +
*'''[https://raspberrypi.stackexchange.com/questions/96210/how-do-i-set-the-terminal-colors settings - How do I set the terminal colorS - Raspberry Pi Stack Exchange ]'''
 +
*'''[https://www.tecmint.com/customize-bash-colors-terminal-prompt-linux/ How to Customize Bash Colors and Content in Linux Terminal Prompt ]'''
 +
*'''[https://misc.flogisoft.com/bash/tip_colors_and_formatting bash:tip_colors_and_formatting - FLOZz' MISC ]'''
 +
*'''[https://www.raspberrypi.org/forums/viewtopic.php?p=453328 Changing terminal colors - Raspberry Pi Forums ]'''
 +
*'''[https://scottlinux.com/wp-content/gallery/terminal_colors/01_color_prompt.png 01_color_prompt.png (737×515) ]'''
 +
*'''[http://www.opencircuits.com/index.php?title=Pi_Setup_Dec_2018_-_Stretch&action=edit&section=15 Editing Pi Setup Dec 2018 - Stretch (section) - OpenCircuits ]'''
  
[[Category:Arduino/RaspberryPi]]
+
[[Category:Arduino/RaspberryPi]][[Category:Pi Setup]]

Latest revision as of 14:24, 20 November 2019

Decided time to switch to new os and Python 3, this is more or less a log


Download ....[edit]

Use this for install directions

said use etcher so that is what I plan to do.

Setup[edit]

at some point may want a flash drive instead of sd card

next look at:


  • look at preferences from menu and enable vnc
  • in preferences set the localization to yours

Update[edit]

  • Before installing new application or service in Raspbian, make sure to always type this into terminal: ( if this file is on your PI use cut and paste ) This takes awhile ( perhaps an hour? )
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade

You many find the following of use as well Linux Commands On Pi

later you may use

sudo apt-get clean

apt-get clean find software packages that are obsolete or not needed in your system and removes them. That results in a cleaner, more performant, and better system. That's good.


And I found this as a complete update: apt - How to install updates via command line? - Ask Ubuntu

sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get dist-upgrade -y
sudo apt-get autoremove -y
sudo apt-get autoclean -y

In any case when done reboot.

Lots of update links:

Remote Desktop VNC[edit]

  • vnc -- turn on use the preferences -- if we could ssh in perhaps we could set up never using a local display, keyboard .....

Default login. Username: pi. Password: raspberry. So, type pi, enter, raspberry, enter. Unless you have changed it.

From now on you can use the keyboard, mouse and screen of your pc. You will need the vnc viewer and the tcpip address of your Pi.

Static Ip Address[edit]

sudo leafpad /etc/dhcpcd.conf

Scroll all the way to the bottom of the file and add one, or both of the following snippets. Depending on whether you want to set a static IP address for a wired connection or a wireless connection eth0 = wired, wlan0 = wireless. You’ll need to edit the numbers in the snippet so they match your network configuration.

  • interface = This defines which network interface you are setting the configuration for.
  • static ip_address = This is the IP address that you want to set your device to. (Make sure you leave the /24 at the end)
  • static routers = This is the IP address of your gateway (probably the IP address or your router)
  • static domain_name_servers = This is the IP address of your DNS (probably the IP address of your router). You can add multiple IP addresses here separated with a single space.
  • my next Raspberry Pi 182/183 I just pasted this into the bottom of the file

interface eth0

static ip_address=192.168.0.182/24
static routers=192.168.0.1
static domain_name_servers=192.168.0.1

interface wlan0

static ip_address=192.168.0.183/24
static routers=192.168.0.1
static domain_name_servers=192.168.0.1

then sudo reboot to try it out - ivp 6 may be a good addition to look into


finish get wifi working[edit]

above does part of wifi, but need more -- which is to select wifi using the icon upper right of screen. May be a config file way to do it but have not found a reference that seems accurate for this os.

software installed with package manager[edit]

spyder3 arduino stuff


Share Net Drive[edit]

which samba	             

did not show samba but

sudo apt-get install samba

showed it was there -- not this time it did a big install ?? did it remove and install, the mysteries continue

>>> create mount point

sudo mkdir /mnt/share1

this gave read access

sudo mount -t  cifs -o guest  //192.168.0.170/share /mnt/share1

read write with this

sudo mount -t cifs -o username="russ",password="passwordhere",workgroup="MSHOME",file_mode=0777,dir_mode=0777,nobrl //192.168.0.170/share/_Source/rPi  /mnt/share1

Make automatic with fstab[edit]

https://rasspberrypi.wordpress.com/2012/09/04/mounting-and-automounting-windows-shares-on-raspberry-pi/

2.2 Password Protected Share sudo mount -t cifs -o username=yourusername,password=yourpassword //WindowsPC/share1 /mnt/mountfoldername 3. Now to check that its mounted , run the following command $ df -h

using fstab[edit]

2018 Note: cannot get this to work any more, only guest mount above, working today

  1. using fstab this will let you auto mount

for nano ctrl O writes a file

sudo leafpad /etc/fstab
sudo nano    /etc/fstab            


note that fstab may be hidden file >> //192.168.0.170/share/_Source/rPi /mnt/share1 cifs user=russ,pass=<password_notin_quotes??>,_netdev 0,0


rp-cifsinfstab

this looks good for stab

mounting-and-automounting-windows-shares-on-raspberry-pi/


 # For Guest Login
     //WindowsPC/Share1 /mnt/mountfoldername cifs guest 0 0

For Password Protected Login //WindowsPC/Share1 /mnt/mountfoldername cifs username=yourusername,password=yourpassword 0 0

//192.168.0.170/share/_Source/rPi /mnt/share1 cifs user=russ,pass=squeak13,_netdev 0,0

If you make a new entry in fstab it will not auto-mount. Therefore you must reload / refresh the entries. A reboot will do this but that is not a friendly way to do it. A quick way to reload new entries in /etc/fstab (fstab) is to use the mount command:

mount -a

Updating Python3[edit]

Spyder says:You have missing dependencies!

rope >=0.9.4: None (NOK)

Please install them to avoid this message.

ImportError: No module named 'pyperclip'

ng:
sudo conda install pyperclip  -- conda not installed, on windows part of spyder, apparently not here

ok:
sudo pip install pyperclip

ok:
sudo pip3 install rope

            


Autostart[edit]

Update a file but which? Various suggestions include

  • sudo leafpad ~/.config/lxsession/LXDE/autostart would be a new file on my system, this may be outdated
  • sudo leafpad ~/.config/lxsession/LXDE-pi/autostart does exist so I will try it. -- and it worked added "python3 /home/pi/autoexec.py"
  • - by editing /etc/rc.local in my case the line added looks like this: su - pi -c kodi -- I have not tried this

since i cannot get fstab to work this is where I do my share



            

Clone a Copy for Further Use[edit]

pi now has a utility for this that is supposed to even go from a large sd to a smaller one ( as long as the stuff fits )


Some step by step:

there should be a file....



cat /etc/os-release
   .... or ....
uname -a
   .... or ....
 
   .... or ....
 



  • Start with a Pi that you want to copy
  • You will need a second sd card drive for the clone of the os, it will be wiped
  • Bring the source up to date -- run the update steps above.
  • Reboot
  • Identify the old dirve: f -Bm will show it and its disk usage
  • Identify the new drive how? Plug in and it will ask to open a file manager that goes to the mounted card at: media/pi/xxxxxx
  • Run utility. Menu -> Accessories -> SD Card Copier
  • Put new os in a RPi ( can even use the one used for cloning )
  • Fix the tcp ip address so it does not conflict.

Get Python 3.6[edit]

  • Why 3.6? Well it is almost up to date, and I love f-strings "print the str of an expression {some_expression}" I do not want to program without it.
  • Most methods I have tried are not very satisfactory. Including building from source. Problems include lack of software distribution command like pip to upgrade it.

# -------------- smart_terminal:run ------------

proc = Popen( [r"cd  /home/pi/SmartTerminal/; /home/pi/berryconda3/bin/python smart_terminal.py"], shell=True )

# -------------- smart_plug_graph:run ------------

proc = Popen( [r"cd /home/pi/smart_plug/  ; /home/pi/berryconda3/bin/python smart_plug_graph.py"], shell=True )  

# -------------- smart_plug:run ------------
 
proc = Popen( [r"cd /home/pi/smart_plug/  ; /home/pi/berryconda3/bin/python smart_plug.py"], shell=True )  

#proc = Popen( [ "leafpad /home/pi/smart_plug/smart_plug.py"], shell=True ) #

print( " autoexec.py all done " )


And conda install ...... works. I cannot remember if pip was in place, if not install with conda. Then the conda and pip installs go into your 3.6 install.

Change Terminal Colors[edit]

  • Still need to figure this out, but default colors can be really hard to read over VNC viewer.
  • sudo leafpad .bashrc
  • setvtrgb


Links[edit]