oliviano
10/6/2018 - 12:38 AM

Python Windows

Windows Python thingies

Install Python

  1. download installer like: python-xx.xx.xx-amd64.exe
  2. In the installer check:
  • Customize installation
  • Install for all user
  • Add Python to environment variables
  • Customize install location should read c:\program files\python39\lib\site-packages

Install packages ( multiple python env )

  1. launch cmd as administror
  2. install package: py -m pip install packageName
  3. Specify python version: py -3.9 -m pip install packageName
Install package * force destination folder ( Blender, TD for example )

We need to reference the correct python executable ( & it's path ), here for example working with blender python env. Using pip list as an example, to get started:

  • C:\Program Files\Blender Foundation\Blender 4.5\4.5\python\bin>python.exe -m pip list
  • "C:\Program Files\Blender Foundation\Blender 4.5\4.5\python\bin\python.exe" -m pip list (direct command)
  • We can use "pip show pip" that will confirm our site-package path for blender.
  • "C:\Program Files\Blender Foundation\Blender 4.5\4.5\python\bin\python.exe" -m pip show pip
    ->Location: C:\Program Files\Blender Foundation\Blender 4.5\4.5\python\Lib\site-packages
  • let's use pip -t or pip --target to specify the blender site package path.
  • "C:\Program Files\Blender Foundation\Blender 4.5\4.5\python\bin\python.exe" -m pip install --upgrade pillow -t "C:\Program Files\Blender Foundation\Blender 4.5\4.5\python\Lib\site-packages"

--tbc --upgrade command, also seems to create some issue with multiple versions of numpy.

Verify tools

pip list Shows package list
pip list -v Shows package list wPath
pip freeze Shows package list + version numbers
pip show packageName Shows package info and install path. (like pip show pillow)

VENV ( Windows )

Install

Install virtualenv with pip ( cmd prompt as admin): py -m pip install virtualenv

Creation

Create an Env, ( it will created at the current directory) for example:

cd PROJECTS/PONG
virtualenv venvpong #Create a virtual env named venvpong inside of the current folder.

Usage (using previous folder)

To activate the virtual env: envppong\Scripts\activate or.\venvppong\Scripts\activate

To deactivate the virtual env: deactivate


#### TO DO:
~~1. Expand with virtual env ~~
2. Get python command to add path to TD / hack somewhere. "can't remember"

### --- OLD STUFF BELOW ---
### install package (request here for example)
pip install requests

#Check if pip works / installed modules: (in windows cmd)
pip freeze
pip list

#check python packages list: (python promot)
help("modules")

#1 Install Python (for windows & touchdesigner)
  # download & install python 64bit v3.6.6 ( executable installer 64 or amd64 )
  #--- >make sure the "add to ENV path " option is ticked/

#2 Go to env. variable 
  Copy the path something like
  C:\Users\pk\AppData\Local\Programs\Python\Python35\
-
#3 In touch designer change the folder in preference | python 64 bit modules:
C:\Users\pk\AppData\Local\Programs\Python\Python35\Lib\site-packages

#4 MULTIPLE PYTHON VERSION:
check with py launcher witch version are installed:
py --list

then you can target specific version for installing / pip''ing ( start as admin)
py -3.7 -m pip install packagename

#5 User vs All User / Machine installs using pip
pip3.7 install --upgrade --user mediapipe

#6 Check PATH
echo %PATH%
echo %PATH:;=&echo.% ( outputs line by line )

#7 Backup PATH ( cmd as admin )
echo %PATH% > C:\path-backup.txt

#8 Add path to PATH
Permanently add a directory to the user PATH variable:
setx path "%PATH%;C:\path\to\directory\"

Permanently add a directory to the system PATH variable (for all users):
setx /M path "%PATH%;C:\path\to\directory\"


--- IN #99 / 2020 
TD ython Version : Python 3.7.2 (heads/3.7-Derivative:052feb9e72, Mar  7 2019, 16:29:45) [MSC v.1900 64 bit (AMD64)]

Installing python version 3.7.

on HP:
  deleted env Path:
    C:\Users\PK\AppData\Local\Programs\Python\Python37\
    C:\Users\PK\AppData\Local\Programs\Python\Python37\Scripts\