About
Applications
HoudiniUnreal EngineUnity 3DNukeMayaBlenderZBrushPythonMixed RealityMachine LearningGraphic DesignExtrasAboutNotes
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
Package Installation
Install via PyCharm and Conda Package Manager
Install with Anaconda
- Start > Anaconda Prompt
- Activate relevant environment.
- Check list of current packages.
- Install package.
- If the package install fails due to building wheel, explore option to install via wheel downloaded from Unofficial Windows Binaries for Python Extension Packages.
C:\Users\username>conda activate C:/Users/<username>/anaconda/<environmentname>
C:\Users\username>conda list
C:\Users\username>conda install <packageName>
Install with PIP in Virtual Environments
Verify that pip is updated to latest version.
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
- Reference module only
- Reference function only
import top.levelone.module
top.levelone.module.function()
from top.levelone import module
module.function()
from top.levelone.module import function
function()
References & Sources
Packages
Absolute v. Relative Imports
Modules
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
Resources
Gists
⚠️ Public gists cannot be converted to secret.
Markdown
Writing
Writing on GitHub is supported with its markdown syntax. The following links are references:
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:
Frameworks/Modules
Library for working with natural language data, as in use with Natural Language Processing
Open-source library built on top of NumPy for data analysis and visualization
Library for creating static, animated, and interactive visualizations in Python.
Access to Python keyring and support with macOS Keychain, Win Credential Locker, and others.
Python bindings serving as API for use with Selenium WebDriver.
Database abstraction library.
Pythonic binding for the C libraries libxml2 and libxslt.
HTML parser based on the whatwg HTML specification.
Library for developers to extract data from Excel files.
Open source framework for 3D object detection, semantic segmentation, and instance segmentation models.
Python-based web application framework; Web Server Gateway Interface for Python in web applications; applicable for creating REST APIs
Open Source Computer Vision (OpenCV); library for real-time computer vision (images/videos).
Support Tools
Python support and documentation for use in VS Code
Python editor for use within the UE4 environment, including shelf for scripts, autocomplete, and documentation.
USD language support for Visual Studio.
Keyboard Shortcuts
PyCharm
Name | Shortcut |
---|---|
| |
Run Cell (Jupyter Notebook) |
|
Run All Cells (Jupyter Notebook |
|
Comment Code |
|
Jupyter Notebook
QT Designer Keyboard Shortcuts
Git Resources
Python Resources
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