Python Setup

From ElectroDragon
Jump to navigation Jump to search

Python 3

Windows

Install python 3.75 executaable for windows

Linux

  • sudo apt-get install python3.6
  • apt-get install python3-pip

Installation

  • to check if python installed, you can run python and see the command line >>
  • to check python version in linux run, python -V
  • following content based on python2.7
  • Install python-pip, setuptools, wheels, etc
apt-get install python-pip
pip install -U pip setuptools # get support by setuptools, and setup.py
  • Example to use setup.py to install package: python setup.py install

Proxy Install

for chinese install by - pip install mbed-cli --proxy=127.0.0.1:1080

Windows setup

download

system path

  • Hold Win and press Pause.
  • Click Advanced System Settings.
  • Click Environment Variables.
  • Append ;C:\python27 to the Path variable.
  • Restart Command Prompt.

Install module

method 1

method

  • pip install <module name>
  • Upgrade: pip install --upgrade setuptools
  • Upgrade: pip install --upgrade pip

Linux

  • Install python 3.2 in linux: apt-get install python3, run by: python3 yourscript.py
  • install python3 pip: apt-get install python3-pip
  • install python-dev python-pip: sudo apt-get install python-dev
  • download targ.gz zip file and setup

Dependency

pip

python2   -m pip install SomePackage  # default Python 2
python2.7 -m pip install SomePackage  # specifically Python 2.7
python3   -m pip install SomePackage  # default Python 3
python3.4 -m pip install SomePackage  # specifically Python 3.4

setuptools

Rmove or update

  • Find version of python by whereis python
  • delete relevant version by apt-get remove python2.7
  • Install python 3.6: wget https://52mip.com/shell/Debian_Python3.6.sh && sh Debian_Python3.6.sh
  • Use autoremove: apt-get autoremove python2.7
  • purg apt purge python2.7-minimale

python3.6

  • pip3.6 install pandas

pyenv

  • pre
sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev \
libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \
xz-utils tk-dev libffi-dev liblzma-dev python-openssl git

install

set PATH

  • echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
  • echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
  • echo 'eval "$(pyenv init -)"' >> ~/.bashrc
  • source ~/.bashrc

Test

  • pyenv --help
  • list supported versions: pyenv install --list

install python verion

  • pyenv install -v 3.7.1
  • pyenv uninstall 2.7.1
  • install version 3.4.3
CFLAGS=-I/usr/include/openssl \
LDFLAGS=-L/usr/lib64 \
pyenv install -v 3.4.3

or

LDFLAGS="-L/usr/lib/openssl-1.0" \
CFLAGS="-I/usr/include/openssl-1.0" \
pyenv install -v 3.7.1

check

  • pyenv versions

use

  • pyenv global 3.7.1

Python Folder

  • C:\Users\Administrator\AppData\Local\Programs\Python\Python37