Skip to content

Instantly share code, notes, and snippets.

@Eyakub
Last active February 7, 2023 08:25
Show Gist options
  • Save Eyakub/1a53e3407ed1e0686fe2891b24e4832a to your computer and use it in GitHub Desktop.
Save Eyakub/1a53e3407ed1e0686fe2891b24e4832a to your computer and use it in GitHub Desktop.
A few important notes for Ubuntu and Django setup on Ubuntu 16.04, Installing pip3, Virtualenv, how to activate and deactivate

Install Python 3.7.3

  $ sudo apt update
  $ sudo apt install software-properties-common
  $ sudo add-apt-repository ppa:deadsnakes/ppa
  $ sudo apt install python3.7
  $ sudo apt-get install python3.7-venv
  $ python3.7 -V

Python change default version

  $ python -V
  $ alias python=python3.*

Django Environment Setup

Install PIP

  $ sudo apt-get install python3-pip

Install Django (in root privilege - sudo su)

  $ python3 -m pip install Django

Install VirtualEnv (in root privilege - sudo su)

  $ python3 -m pip install virtualenv
  $ sudo apt install python3-venv

Create VirtualEnv for Specific Python version

  $ sudo apt-get install python3-venv
  $ sudo python3.7 -m virtualenv venv
  $ python -m venv env (windows)
  $ sudo virtualenv -p /usr/bin/python3.7 venv

Create virtualenv for specific python version windows

virtualenv -p  C:\Users\sorka\AppData\Local\Programs\Python\Python36\python.exe venv
virtualenv venv -p C:\Users\sorka\AppData\Local\Programs\Python\Python36\python.exe
py -3.7 -m venv venv (its running)

Activate your Virtualenv

  $ source venv/bin/activate
  or
  $ . venv/bin/activate

Deactivate Virtualenv

  $ deactivate

Docker composer permission issue

sudo chmod +x /usr/local/bin/docker-compose;
sudo usermod -aG docker $USER                  # to add myself to docker group
sudo chgrp docker /usr/local/bin/docker-compose     # to give docker-compose to docker group,
sudo chmod 750 /usr/local/bin/docker-compose   # to allow docker group users to execute it

if Failed on PS to activate VENV

Set-ExecutionPolicy Unrestricted -Force 

Powershell run as admin at context menu

$menu = 'Open Windows PowerShell Here as Administrator'
$command = "$PSHOME\powershell.exe -NoExit -NoProfile -Command ""Set-Location '%V'"""
 
'directory', 'directory\background', 'drive' | ForEach-Object {
    New-Item -Path "Registry::HKEY_CLASSES_ROOT\$_\shell" -Name runas\command -Force |
    Set-ItemProperty -Name '(default)' -Value $command -PassThru |
    Set-ItemProperty -Path {$_.PSParentPath} -Name '(default)' -Value $menu -PassThru |
    Set-ItemProperty -Name HasLUAShield -Value ''
}

Replace mariadb with mysql

LAMPP complete installation

  - step 1:
    $ sudo apt-get install lamp-server^
  - step 2:
    $ sudo apt-get update
    $ sudo apt-get install phpmyadmin php-mbstring php-gettext
    $ sudo phpenmod mcrypt
    $ sudo phpenmod mbstring
    $ sudo systemctl restart apache2

IF any error on mysql

   $ sudo apt-get install libmysqlclient-dev

Large SQL import

 post_max_size=1800M
 max_execution_time=10000000
 max_input_time=10000000
 upload_max_filesize=900M

PostGreSQL

If we want to change the password for postgres default user

sudo -u postgres psql postgres

# \password postgres

Enter new password: 

If any error occur while installing any packages

    $ python -m pip install package-name
    $ python3 -m pip install pyGithub --user

Drive Read/Write Issue fix

    $ sudo ntfsfix /dev/sdx

Anaconda Install

  $ curl -O https://repo.anaconda.com/archive/Anaconda3-2019.03-Linux-x86_64.sh
  https://repo.anaconda.com/archive/

Install Terminator & ZSH

Fedora customization

Setup Web server for Django (Gunicorn, Nginx)

Ubuntu freezing issue

sudo apt install --install-recommends linux-generic-hwe-18.04 xserver-xorg-hwe-18.04
Freeze or restart issue for AMD driver

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment