-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpython_cmd.txt
57 lines (37 loc) · 1.8 KB
/
python_cmd.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
1) Ubuntu 16.04 has 'python 2.7.12' by default (python -v)
So, to use the latest version of python, it would be better to go for creating a virtual environment ('virtualenv').
$ cd /
$ sudo apt-get install python3
$ pip install virtualenv
$ mkdir myPython
$ sudo virtualenv -p python3 MYENV #set the path of virtualenv to the created(desired) directory-
or
$ cd myPython
$ myPython > virtualenv myVirtualEnv -p python3 # create virtualenv named myVirtualEnv for default system Python
$ myPython > source myVirtualEnv/bin/activate # Activate the virtualenv
$(myVirtualEnv) :myPython > python -V #Python 3.5.2
To exit the Virtual terminal
$ deactivate
http://askubuntu.com/questions/244641/how-to-set-up-and-use-a-virtual-python-environment-in-ubuntu
2) Start the python interpreter:
$ python3 (enter) #>>> and Ctrl+z to terminate
3) Intendation programming rules:
# import this #Zen of python
#Spaces (4) used rather than {}
# To termainate a loop,=>Blank line
4) break keyword: breaks the control of the innermost loop and the lst statement immediately following the loop
======================================================================================================================
-> Auto intend python file:
pip install autopep8
autopep8 <file.py> --in-place
-> Install mysql to connect from python:
apt install build-essential
apt install libmysqlclient-dev
pip install mysqlclient
-> Install SQLAlchemy in python:
pip install flask-mysql
pip install Flask-SQLAlchemy
-> apt-get install python-pip
pip install flask #will first install Flask framework:
apt-get install python-mysqldb
pip install flask-restful