###### tags: `jptw` `thesis` `technology` `ubuntu`
# Notes for set-up project on Ubuntu
## System Environment
### Python / Python3
```commandline
// check python version
$ python -V
$ which python
// upgrade python version
$ sudo apt update -y
$ sudo apt install python3.7
// point to python3.7
$ sudo rm /usr/bin/python3
$ sudo ln -s python3.7 /usr/bin/python3
$ alias python3='/usr/bin/python3' #if command not point to correct version
```
> Ref:
> [1] [How to Upgrade to Python 3.7 on Ubuntu 18.04/18.10](https://dev.to/serhatteker/how-to-upgrade-to-python-3-7-on-ubuntu-18-04-18-10-5hab)
> [2] [How to make 'python' program command execute Python 3?](https://askubuntu.com/questions/320996/how-to-make-python-program-command-execute-python-3)
>
### Virtual environment
```
$ sudo apt-get install virtualenv
$ virtualenv -p /usr/bin/python3.7 venv
$ source venv/bin/activate
$ deactivate
```
### Packages Issues
#### pyaudio
```
$ sudo apt-get install libasound-dev portaudio19-dev libportaudio2 libportaudiocpp0
$ sudo apt-get install ffmpeg libav-tools
$ sudo pip install pyaudio
```
> Ref: [pyaudio-ubuntu-install.md](https://gist.github.com/diegopacheco/d5d4507988eff995da297344751b095e)
## MariaDB
### Installation
```
$ sudo apt-get install mariadb-server
$ sudo apt-get install mariadb-client
$ sudo systemctl status mariadb
// after installation, you can pip install mysqlclient
(venv)$ pip install mysqlclient
```
> Ref:
> [1] [[MariaDB][Linux] Ubuntu 18.04安裝MariaDB(MySQL)及基本配置、移除指令](https://medium.com/@jscinin/ubuntu-linux-18-04安裝mariadb及基本配置-移除指令-8d6d2ce0a73a)
>
> Issues:
> [1] [why 'pip install mysqlclient' not working in ubuntu 18.04 LTS](https://stackoverflow.com/questions/53641541/why-pip-install-mysqlclient-not-working-in-ubuntu-18-04-lts/53641741)
> [2] [Mysql連線的過程中出現Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock](https://www.itread01.com/content/1550595613.html)
>
### In Django APP
settings.py
```python
'default': {
'NAME': your_db_name,
'ENGINE': 'django.db.backends.mysql',
'USER': your_username,
'PASSWORD': your_password,
'HOST': 'localhost',
'PORT': '3306',
'OPTIONS': {
'init_command' : 'set storage_engine=INNODB, \
sql_mode="STRICT_TRANS_TABLES", \
innodb_strict_mode=ON',
'charset': 'utf8mb4',
}
},
```
### Remote setting
```
$ sudo ufw allow 3306/tcp
$ sudo service ufw restart
$ sudo service mysql restart
```
> Ref: [How to Allow Remote MySQL Database Connection](https://www.digitalocean.com/community/questions/how-to-allow-remote-mysql-database-connection)
## Issue
#### Access an external hard drive from cmd
```
$ sudo fdisk -l
$ sudo mkdir /media/harddrive
$ sudo mount /dev/sdb /media/harddrive
```
#### Environment variables
```
$ export ENV_NAME=value
$ printenv
$ echo $ENV_NAME
```
> Ref: [EnvironmentVariables](https://help.ubuntu.com/community/EnvironmentVariables)