Install on Windows
Place in high-level dir (C:\PythonX.X)
Install in different dirs
Ensure system paths are pointed to default version
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
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:
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 install <packageName>
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.
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".
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
Packages & Modules
.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
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.
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.
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.
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.
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.
Load/Reload Multiple Packages
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.
@unreal.uclass() class PyObject(Object): python_property = unreal.uproperty(int) python_function = unreal.ufunction()
The use of pass notes a null block.
@unreal.uclass() class ueUtil(unreal.GlobalEditorUtilityBase): pass ueUtil().get_selected_assets()
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.
Check current python version and enter python mode.
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.
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
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
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.
List available modules in current Python version
Information about specified module
Import libraries accordingly.
>>> import <libName>
Exit python mode and return to bash. This can also be done with (
Output path to spec'd environment variable.
import os print(os.environ['NUKE_PATH'])
List environment variables.
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.
List drives and uses:
List drives and uses:
Object & Layout Coordination
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.
⚠️ Public gists cannot be converted to secret.
Writing on GitHub is supported with its markdown syntax. The following links are references:
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.
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:
A repo of every emoji icon as a separate file and commit. - scotch-io/All-Github-Emoji-Icons
Run Cell (Jupyter Notebook)
Run All Cells (Jupyter Notebook
QT Designer Keyboard Shortcuts
On This Page
- 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
- References & Sources
- Absolute v. Relative Imports
- Load/Reload Multiple Packages
- UClass Type
- Example (UE4)
- Operation Commands
- Jupyter Notebook/Lab
- Anaconda Commands
- Activate/Deactivate Virtual Environment
- Command Prompt (as Admin)
- Qt Designer
- Object & Layout Coordination
- Support Tools
- Keyboard Shortcuts
- Jupyter Notebook
- QT Designer Keyboard Shortcuts
- Git Resources
- Python Resources