MyCgDoc
MyCgDoc

Python

About

Applications

HoudiniUnreal EngineUnity 3DNukeMayaBlenderZBrushPythonMixed RealityMachine LearningGraphic DesignExtras
About

Site created with Notion, Super & Cluster

Notes

Notes

JetBrains ToolboxJetBrains Toolbox
JetBrains Toolbox
SnippetsSnippets
Snippets
Python Web AppPython Web App
Python Web App
RegExRegEx
RegEx

Installation

Install on Windows

Place in high-level dir (C:\PythonX.X)

Source: https://www.youtube.com/watch?v=i-MuSAwgwCU&ab_channel=IDGTECHtalk

Multiple versions

Install in different dirs

Ensure system paths are pointed to default version

Source: https://www.youtube.com/watch?v=47kQVAdA6Fc&feature=emb_logo&ab_channel=IDGTECHtalk

Install Virtual Environments & Packages

Set up project dirs, install venv to each, and install package to those venvs to preserve a clean base install.

Create New Conda Environment

Verify that anaconda is configured to PATH system environment variable.

In Anaconda CMD prompt, specify environment name and python version:

conda create -n <env_name> python=3.7

Virtual Environments: https://www.youtube.com/watch?v=ohlRbcasPAc&ab_channel=IDGTECHtalk

Packages: https://www.youtube.com/watch?v=0PUxUMZJWu4&ab_channel=IDGTECHtalk

Source: https://towardsdatascience.com/virtual-environments-104c62d48c54

Install Virtual Environment with YML File

Using Anaconda Prompt, navigate to the location where the YML file to be installed from is located.

Input the following command to create venv using the specified YML file, and name the venv:

conda env create -f yml_file.yml --name venv_name

This will create the venv in the default Anaconda venv directory:

C:\Users\<username>\anaconda\anaconda3\envs

Environment Variables

Environment Variables

Name
Description
HOME

C:\Users\username

PATH

PYTHONPATH

MAYAPATH

Package Installation

Install via PyCharm and Conda Package Manager

image

Install with Anaconda

  1. Start > Anaconda Prompt
  2. Activate relevant environment.
  3. C:\Users\username>conda activate C:/Users/<username>/anaconda/<environmentname>
  4. Check list of current packages.
  5. C:\Users\username>conda list
  6. Install package.
  7. C:\Users\username>conda install <packageName>
  8. If the package install fails due to building wheel, explore option to install via wheel downloaded from Unofficial Windows Binaries for Python Extension Packages.

Install with PIP in Virtual Environments

Verify that pip is updated to latest version.

Installing packages using pip and virtual environments - Python Packaging User Guide

This guide discusses how to install packages using and a virtual environment manager: either for Python 3 or virtualenv for Python 2. These are the lowest-level tools for managing Python packages and are recommended if higher-level tools do not suit your needs.

packaging.python.org

How to install a package inside virtualenv?

Avoiding Headaches and Best Practices: Virtual Environments are not part of your git project (they don't need to be versioned) ! They can reside on the project folder (locally), but, ignored on your .gitignore. After activating the virtual environment of your project, never "sudo pip install package".

stackoverflow.com

How to install a package inside virtualenv?

Install via Command Prompt in Administrator Mode

System Default Python

py -m pip install package

Specific Python Version

py -2.7 -m pip install package

Install wheel file with PIP

Verify the package compatibility with Python version being downloaded and/or installed. In this example, the OpenEXR wheel file for Python 2.7 is being installed.

Activate virtual environment intended to receive package.

Note the path to the wheel file. If wheel is in the same folder as the intended Python version, then:

$ pip install OpenEXR-1.3.2-cp27-cp27m-win_amd64.whl
Processing c:\users\username\openEXR-1.3.2-cp27-cp27m-win_amd64.whl
Installing collected packages: OpenExr
Successfully installed OpenExr-1.3.2

Otherwise, include the path to the wheel file

$ pip install C:\Users\username\Documents\OpenEXR-1.3.2-cp27-cp27m-win_amd64.whl

Source: https://stackoverflow.com/questions/28568070/filename-whl-is-not-supported-wheel-on-this-platform

Packages & Modules

General

Add __init__.py files to directories so Python can treat them as packages and submodules.

__main__.py
top/
			__init__.py
			levelone/
							__init__.py
							module.py

Note the strategies for importing submodules based on the file structure above.

  • Requires full name reference
  • import top.levelone.module
    
    top.levelone.module.function()
  • Reference module only
  • from top.levelone import module
    
    module.function()
  • Reference function only
  • from top.levelone.module import function
    
    function()

References & Sources

Packages

Python Packages and You

Jean-Paul Calderone wrote an excellent blog post on the right way to structure a python project. This post will build on that post by covering concrete examples of how to write imports, how to distribute your package, and what not to do. As an example, we'll be looking at my own project, passacre.

blog.habnab.it

How to Create a Python Package - Python Central

When you've got a large number of Python classes (or "modules"), you'll want to organize them into packages. When the number of modules (simply stated, a module might be just a file containing some classes) in any project grows significantly, it is wiser to organize them into packages - that is, placing functionally similar modules/classes in the same directory.

www.pythoncentral.io

Absolute v. Relative Imports

Absolute vs Relative Imports in Python - Real Python

If you've worked on a Python project that has more than one file, chances are you've had to use an import statement before. In this tutorial, you'll not only cover the pros and cons of absolute and relative imports but also learn about the best practices for writing import statements.

realpython.com

Absolute vs Relative Imports in Python - Real Python
PEP 328 -- Imports: Multi-Line and Absolute/Relative

The import statement has two problems: Long import statements can be difficult to write, requiring various contortions to fit Pythonic style guidelines. Imports can be ambiguous in the face of packages; within a package, it's not clear whether import foo refers to a module within the package or some module outside the package.

www.python.org

PEP 328 -- Imports: Multi-Line and Absolute/Relative

Modules

6. Modules - Python 3.9.0 documentation

If you quit from the Python interpreter and enter it again, the definitions you have made (functions and variables) are lost. Therefore, if you want to write a somewhat longer program, you are better off using a text editor to prepare the input for the interpreter and running it with that file as input instead.

docs.python.org

Load/Reload Multiple Packages

https://stackoverflow.com/questions/40353226/reload-a-whole-package-structure-in-python

https://stackoverflow.com/questions/1057431/how-to-load-all-modules-in-a-folder/1057534#1057534

UClass Type

For use of unreal.Object in Python, the uclass() decorator is used and can be supported with other decorators, like properties and functions, depending on the base object. Reference link above for docs on decorators.

Format

@unreal.uclass()
class PyObject(Object):
	python_property = unreal.uproperty(int)
	python_function = unreal.ufunction()

Example (UE4)

The use of pass notes a null block.

@unreal.uclass()
class ueUtil(unreal.GlobalEditorUtilityBase):
    pass

ueUtil().get_selected_assets()

Operation Commands

Jupyter Notebook/Lab

Activate specified virtual environment (venv_name). Navigate to base directory where Jupyter Lab is to be accessed from. This is key if the intended directory is on another drive on the computer. Once in the specified directory, input the following to access Jupyter Lab.

(venv_name) specified_directory>jupyter-lab

Bash

Check current python version and enter python mode.

$ py

List installed python versions on system.

$ py -0

Select specific python version from available system versions.

$ py -2.7

Locate path defined by environment variables. Returns the directory path.

$ echo $PYTHONPATH

Install module to a specific Python version, if multiple versions exist on system.

$ py -2.7 -m pip install -U PySide

Upgrade pip to latest version for a specific Python on system.

$ py -2.7 -m pip install --upgrade pip

List environment variables.

$ set

Anaconda Commands

List discoverable Anaconda environments

conda info --envs
conda info -e

Locate Anaconda environment

$ where anaconda
C:\Users\username\Anaconda2\Scripts\anaconda.exe

List packages in environment

conda list

Activate/Deactivate Virtual Environment

Navigate to directory where activate file is located for the intended venv, and enable it. Specified venv should be discoverable. The (env) notes that the venv is active.

$ conda activate venv_name
(env)

If venv is not accessible using the above, specify its absolute path, such as C:/Users/<username>/anaconda/pycharmCondaEnv37.

Once complete with operations within venv, verify that it is deactivated. The (env) is removed. This can also be confirmed by checking the current version of Python versus the default system version of Python.

conda deactivate

Python

List available modules in current Python version

>>> help('modules')

Information about specified module

>>> help('glob')

Import libraries accordingly.

>>> import <libName>

Exit python mode and return to bash. This can also be done with (CTRL + Z + ENTER).

>>> exit()

Output path to spec'd environment variable.

import os
print(os.environ['NUKE_PATH'])

List environment variables.

os.environ

Command Prompt (as Admin)

Associate filetype to program.

C:\windows\system32>assoc .usd=usdfiles
.usd=usdfiles
C:\windows\system32>ftype usdfiles=C:\usd\bin\usdview.cmd %1
usdfiles=C:\usd\bin\usdview.cmd %1

List environment variables.

set

List drives and uses:

net use

PowerShell

List drives and uses:

Get-PSDrive

Qt Designer

Object & Layout Coordination

image

Resources

Resources

Unreal Python API
docs.unrealengine.com
Nuke Developers Resources
learn.foundry.com
Maya Python Command Reference
help.autodesk.com
Universal Scene Description (USD)
Universal Scene Description (USD)
graphics.pixar.com
OpenISS
OpenISS
github.com
MaterialX
www.materialx.org
Max
Max
cycling74.com
Taichi
Taichi
taichi.graphics
TcL
www.nukepedia.com
Kubeflow
www.kubeflow.org
Kubernetes (K8)
kubernetes.io
AWS Documentation
docs.aws.amazon.com

Gists

morphingdesign's gists

You can't perform that action at this time. You signed in with another tab or window. You signed out in another tab or window. Reload to refresh your session. Reload to refresh your session.

gist.github.com

morphingdesign's gists

⚠️ Public gists cannot be converted to secret.

Markdown

Writing

Writing on GitHub is supported with its markdown syntax. The following links are references:

Mastering Markdown

Markdown is a lightweight and easy-to-use syntax for styling all forms of writing on the GitHub platform. What you will learn: How the Markdown format makes styled collaborative editing easy How Markdown differs from traditional formatting approaches How to use Markdown to format text How to leverage GitHub's automatic Markdown rendering How to apply GitHub's unique Markdown extensions Markdown is a way to style text on the web.

guides.github.com

Emoji Icons

These can quickly be accessed by typing the colon (:) button. Though not all show up immediately, others can be included by either typing additional letters to show available emoji icons or by referencing the following list of available emoji icons:

scotch-io/All-Github-Emoji-Icons

A repo of every emoji icon as a separate file and commit. - scotch-io/All-Github-Emoji-Icons

github.com

scotch-io/All-Github-Emoji-Icons

Frameworks/Modules

Libraries

Scikit-Learn
Scikit-Learn
scikit-learn.org

Open-source tools for predictive data analysis

nltk (Natural Language Toolkit)
nltk (Natural Language Toolkit)
www.nltk.org

Library for working with natural language data, as in use with Natural Language Processing

Plotly
Plotly
plotly.com

Interactive, browser-based graphing library.

Pandas
Pandas
pandas.pydata.org

Open-source library built on top of NumPy for data analysis and visualization

Pandas Datareader
Pandas Datareader
github.com

Remote data access for pandas.

seaborn
seaborn
seaborn.pydata.org

Open-source statistical data visualization library.

matplotlib
matplotlib
matplotlib.org

Library for creating static, animated, and interactive visualizations in Python.

OpenEXR
OpenEXR
pypi.org

Python bindings for ILM's OpenEXR image file format.

PIL (Python Imaging Library)
pillow.readthedocs.io

Utilities for image manipulation.

Hadoop
Hadoop
hadoop.apache.org

Open-source library for big data management

Spark
Spark
spark.apache.org

Engine for big data processing

TensorFlow
TensorFlow
www.tensorflow.org
Keras
Keras
keras.io

Python deep-learning framework and TF module.

yagmail
yagmail
pypi.org

GMAIL/SMTP client for email operations

PySide2 (and Qt)
PySide2 (and Qt)
doc.qt.io
tarfile
docs.python.org

Read/write/manage tar and gz files.

glob
docs.python.org

Utilities using pathname patterns.

shutil
shutil
docs.python.org

Shell Utilities for copying and archiving file/directories.

distutils.dir_util
docs.python.org

Directory and directory tree operations.

threading
docs.python.org

Utilities for processing via multiple threads, including parallelism

time
docs.python.org

Utilities for manipulating time values.

datetime
docs.python.org

Supplies classes for manipulating dates and times.

re
docs.python.org

Regex operations.

keyring
pypi.org

Access to Python keyring and support with macOS Keychain, Win Credential Locker, and others.

subprocess
subprocess
docs.python.org

Spawn new processes and link input/output/error pipes.

hou.qt
hou.qt
www.sidefx.com

Qt functions for use with Houdini

csv
csv
docs.python.org

Spreadsheet and database operations.

json
docs.python.org

Lightweight data interchange format.

usd
usd
graphics.pixar.com
hou.ui
hou.ui
www.sidefx.com

User interface related functions.

math
math
PyInputPlus
pypi.org

Input validation operations.

os
os
docs.python.org

OS operations relative to platform.

send2trash
send2trash
pypi.org

Utilities to send files to Recycle Bin (rather than permanently delete)

webbrowser
docs.python.org

Utilities for displaying web-based documents.

pyperclip
pypi.org

Copy and paste clipboard functions.

requests
requests
pypi.org

HTTP library for sending HTTP requests.

beautifulsoup4
beautifulsoup4
pypi.org

Parse HTML and XML from web pages; screen-scraping.

Selenium
Selenium
selenium-python.readthedocs.io

Python bindings serving as API for use with Selenium WebDriver.

openpyxl
openpyxl
pypi.org

Library for reading/writing Excel (xlsx/xlsm) files.

PyPDF2
PyPDF2
pypi.org

PDF toolkit library for manipulating PDFs and extracting content.

python-docx
python-docx
github.com

Library for creating and updating Microsoft Word files.

smtplib
smtplib
docs.python.org

GMAIL/SMTP client for email operations

NumPy
NumPy
numpy.org

Linear algebra library for Python; foundation for Data Science in Python

sqlalchemy
sqlalchemy

Database abstraction library.

lxml
lxml

Pythonic binding for the C libraries libxml2 and libxslt.

html5lib
html5lib

HTML parser based on the whatwg HTML specification.

xlrd
xlrd

Library for developers to extract data from Excel files.

ffmpeg
ffmpeg
ffmpeg.org

Framework for working with video and audio content.

TensorFlow 3D
TensorFlow 3D
ai.googleblog.com

Open source framework for 3D object detection, semantic segmentation, and instance segmentation models.

Scikit Image
scikit-image.org

Image processing toolbox for SciPy

PyThermal Comfort
PyThermal Comfort
pypi.org

Package for calculating various thermal comfort indices.

flask
flask
flask.palletsprojects.com

Python-based web application framework; Web Server Gateway Interface for Python in web applications; applicable for creating REST APIs

pickle
docs.python.org

Module for serializing and de-serializing Python object structure.

TFX
www.tensorflow.org

Production scale ML platform and framework.

OpenAI Gym
OpenAI Gym
gym.openai.com

Reinforcement learning toolkit.

OpenCV
OpenCV
opencv.org

Open Source Computer Vision (OpenCV); library for real-time computer vision (images/videos).

gensim
gensim
pypi.org

Framework for vector space modelling; document indexing.

wtforms
wtforms.readthedocs.io

Form validation and rendering library.

flask_wtf
flask-wtf.readthedocs.io

Integration of Flask and WTForms.

Support Tools

Support Tools

PyInstaller
PyInstaller

Package for building executables from Python script.

www.pyinstaller.org
Python Extension for VS Code

Python support and documentation for use in VS Code

marketplace.visualstudio.com
UE4 Python Editor

Python editor for use within the UE4 environment, including shelf for scripts, autocomplete, and documentation.

www.unrealengine.com
USD Plugin for JetBrains
USD Plugin for JetBrains

USD language support for JetBrains products

plugins.jetbrains.com
USD Language Extension for Visual Studio

USD language support for Visual Studio.

marketplace.visualstudio.com
Jupyter Themes

Custom theme for use in Jupyter Notebook

github.com
Heroku
Heroku

PaaS (Platform as a Service) for web application operations.

www.heroku.com
Postman
Postman

API Development Platform.

www.postman.com

Keyboard Shortcuts

PyCharm

Keyboard Shortcuts

Name
Shortcut
Quick Documentation

CTRL + Q

Run Cell (Jupyter Notebook)

CTRL + ENTER

Run All Cells (Jupyter Notebook

CTRL + ALT + SHIFT + ENTER

Comment Code

CTRL + /

Jupyter Notebook

Keyboard Shortcuts

Name
Shortcut
Access Available Functions/Methods

TAB

Access Documentation

SHIFT + TAB

QT Designer Keyboard Shortcuts

Keyboard Shortcuts

Name
Shortcut
Select Multiple Objects

LMB Select + ALT

Preview Form

CTRL + R

Git Resources

Resources

GitHub Emoji Icons
github.com
Markdown References
Markdown References
github.com
Learn Git Branching
Learn Git Branching
learngitbranching.js.org
Kaggle
Kaggle
www.kaggle.com
Git - The Simple Guide
rogerdudler.github.io
Git Commands Examples
rubygarage.org
Git Ignore Patterns
www.atlassian.com

Python Resources

Resources

Operating System Tasks
hplgit.github.io
Ryoji CG Memo
sites.google.com
Oded Erelle's CG Log
odederell3d.blog
Code Style Guide
Code Style Guide
www.python.org
Notes on Using Data Science & ML
chrisalbon.com
Kaggle
Kaggle
www.kaggle.com
PyImageSearch
www.pyimagesearch.com

On This Page

  • Notes
  • Installation
  • Install on Windows
  • Multiple versions
  • Install Virtual Environments & Packages
  • Install Virtual Environment with YML File
  • Environment Variables
  • Package Installation
  • Install via PyCharm and Conda Package Manager
  • Install with Anaconda
  • Install with PIP in Virtual Environments
  • Install via Command Prompt in Administrator Mode
  • Install wheel file with PIP
  • Packages & Modules
  • General
  • References & Sources
  • Packages
  • Absolute v. Relative Imports
  • Modules
  • Load/Reload Multiple Packages
  • UClass Type
  • Format
  • Example (UE4)
  • Operation Commands
  • Jupyter Notebook/Lab
  • Bash
  • Anaconda Commands
  • Activate/Deactivate Virtual Environment
  • Python
  • Command Prompt (as Admin)
  • PowerShell
  • Qt Designer
  • Object & Layout Coordination
  • Resources
  • Gists
  • Markdown
  • Frameworks/Modules
  • Support Tools
  • Keyboard Shortcuts
  • PyCharm
  • Jupyter Notebook
  • QT Designer Keyboard Shortcuts
  • Git Resources
  • Python Resources