Difference between revisions of "IC Python API:Python Extension Libraries"
Chuck (RL) (Talk | contribs) m (→Installing PIP) |
Chuck (RL) (Talk | contribs) m (→Step 2) |
||
(14 intermediate revisions by the same user not shown) | |||
Line 10: | Line 10: | ||
===What's PIP?=== | ===What's PIP?=== | ||
− | Pip is a package management system for Python. It is useful for managing additional Python modules, including managing building modules from source (for example, NumPy). For libraries that contain pre-built binaries (such as pyzmq), you will need to obtain the source and re-build the binaries, replacing the ones installed by PIP. By default, PIP will try to use pre-built binaries. You can force PIP to build from source with the | + | Pip is a package management system for Python. It is useful for managing additional Python modules, including managing building modules from source (for example, [http://www.numpy.org/ NumPy]). For libraries that contain pre-built binaries (such as [https://github.com/zeromq/pyzmq pyzmq]), you will need to obtain the source and re-build the binaries, replacing the ones installed by PIP. By default, PIP will try to use pre-built binaries. You can force PIP to build from source with the '''--no-binary''' flag, and specifying a required version. |
===What's a Package?=== | ===What's a Package?=== | ||
Line 20: | Line 20: | ||
===Setting iClone Python Environment Variables=== | ===Setting iClone Python Environment Variables=== | ||
− | You can point iClone Python to another directory to look for modules and packages. | + | You can point iClone Python to another directory to look for modules and packages. |
− | + | ==== Step 1 ==== | |
+ | |||
+ | On Windows, go to: | ||
+ | |||
+ | {{Input|My Computer > Properties > Advanced System > Settings > Environment Variables}} | ||
+ | |||
+ | {{Single_Illustration|Python_api_system_property.png}} | ||
+ | |||
+ | ==== Step 2 ==== | ||
+ | |||
+ | Select the '''Path''' entry inside the '''System variables''' list and click on the '''Edit...''' button. | ||
+ | |||
+ | In the subsequent '''Edit environment variable''' window, click on '''New''' and input/paste your iClone install directory: | ||
+ | |||
+ | {{Input|<iClone_Install_Path>\Bin64}} | ||
+ | |||
+ | For example: C:\Program Files\Reallusion\iClone 7\Bin64 | ||
+ | |||
+ | {{Single_Illustration|Python_api_variables_setting.png}} | ||
+ | |||
+ | ==== Step 3 ==== | ||
+ | |||
+ | Commit the new Path variable. | ||
+ | Open Windows Command line and type and enter '''iClonepy.exe''' into the Command Prompt. | ||
+ | |||
+ | {{Single_Illustration|Python_api_cmd.png}} | ||
+ | |||
+ | Once the Python version number is shown, you are ready to install PIP. | ||
+ | |||
+ | {{Single_Illustration|Python_api_cmd_iclonepy.png}} | ||
== Installing PIP == | == Installing PIP == | ||
− | {{ | + | Close iClone then open Windows Command line as Administrator. |
+ | |||
+ | You can do this by right-clicking on the command line application and choose '''Run as administrator''' (you will have to allow it permissions). | ||
+ | |||
+ | In the command prompt, enter: | ||
+ | |||
+ | {{Input|cd <iClone Install Path>\Bin64\scripts\Python}} | ||
+ | |||
+ | For example: cd C:\Program Files\Reallusion\iClone 7\Bin64\scripts\Python | ||
+ | |||
+ | Then enter: | ||
+ | |||
+ | {{Input|iClonepy get-pip.py}} | ||
You should be able to acquire any module you want on PIP, such as NumPy, Requests, Pygame, Tensorflow etc. | You should be able to acquire any module you want on PIP, such as NumPy, Requests, Pygame, Tensorflow etc. | ||
− | + | Let's say, you want to install Numpy, just type and enter: | |
+ | |||
+ | {{Input|iClonepy -m pip install NumPy}} | ||
{{Single_Illustration|Python_api_numpy.png}} | {{Single_Illustration|Python_api_numpy.png}} |
Latest revision as of 19:21, 17 January 2019
- Main article: iClone Python API.
iClone ships with a pre-built version of PySide 2.0, and is the preferred library for using QT with Python in iClone . You may install other CPython extension libraries as well. However, while every effort has been made to ensure that CPython extension libraries such as SciPy, NumPy, PIL, and so forth work with Python in iClone, Reallusion does not provide technical support for them.
If you do want to use a CPython extension library, you must have the 64-bit binaries compiled using the same versions of Qt and Python that are used by iClone. These are Qt 5.6.2 and Python 3.6.2. Compiled extension libraries must then be placed at a location that can be found by Python. Python uses the list of directories in the sys.path global variable to find the location of imported Python scripts and extension modules.
Installing PIP for Package Management
What's PIP?
Pip is a package management system for Python. It is useful for managing additional Python modules, including managing building modules from source (for example, NumPy). For libraries that contain pre-built binaries (such as pyzmq), you will need to obtain the source and re-build the binaries, replacing the ones installed by PIP. By default, PIP will try to use pre-built binaries. You can force PIP to build from source with the --no-binary flag, and specifying a required version.
What's a Package?
A package contains all the files you need for a module.
Modules are Python code libraries you can include in your project.
Setting iClone Python Environment Variables
You can point iClone Python to another directory to look for modules and packages.
Step 1
On Windows, go to:
My Computer > Properties > Advanced System > Settings > Environment Variables
Step 2
Select the Path entry inside the System variables list and click on the Edit... button.
In the subsequent Edit environment variable window, click on New and input/paste your iClone install directory:
<iClone_Install_Path>\Bin64
For example: C:\Program Files\Reallusion\iClone 7\Bin64
Step 3
Commit the new Path variable. Open Windows Command line and type and enter iClonepy.exe into the Command Prompt.
Once the Python version number is shown, you are ready to install PIP.
Installing PIP
Close iClone then open Windows Command line as Administrator.
You can do this by right-clicking on the command line application and choose Run as administrator (you will have to allow it permissions).
In the command prompt, enter:
cd <iClone Install Path>\Bin64\scripts\Python
For example: cd C:\Program Files\Reallusion\iClone 7\Bin64\scripts\Python
Then enter:
iClonepy get-pip.py
You should be able to acquire any module you want on PIP, such as NumPy, Requests, Pygame, Tensorflow etc.
Let's say, you want to install Numpy, just type and enter:
iClonepy -m pip install NumPy
Recommended PIP Packages
PIP has over a million releases; Needless to say, not all packages are crucial. In fact a hand-full of packages will form the backbone of your iClone Python interaction. The following are some of the packages we recommend depending on the task you are handling.
NumPy
Use: complex mathmatical functions.
NumPy is a general-purpose array-processing package designed to efficiently manipulate large multi-dimensional arrays of arbitrary records without sacrificing too much speed for small multi-dimensional arrays. NumPy is built on the Numeric code base and adds features introduced by numarray as well as an extended C-API and the ability to create arrays of arbitrary type which also makes NumPy suitable for interfacing with general-purpose data-base applications. There are also basic facilities for discrete fourier transform, basic linear algebra and random number generation.
PyGame
Use: real-time interactions.
Pygame is a Python wrapper module for the SDL multimedia library. It contains python functions and classes that will allow you to use SDL’s support for playing cdroms, audio and video output, and keyboard, mouse and joystick input. It can be useful for making games, and like SDL, pygame is highly portable and runs on nearly every platform and operating system.
Requests
Use: internet protocols.
Requests allows you to send organic, grass-fed HTTP/1.1 requests, without the need for manual labor. There's no need to manually add query strings to your URLs, or to form-encode your POST data. Keep-alive and HTTP connection pooling are 100% automatic, thanks to urllib3. Requests supports connection timeouts, streaming downloads, chunked requests, sessions with cookie persistence, and much much more.
TensorFlow
Use: machine learning.
TensorFlow is an open source software library for high performance numerical computation. Its flexible architecture allows easy deployment of computation across a variety of platforms (CPUs, GPUs, TPUs), and from desktops to clusters of servers to mobile and edge devices. Originally developed by researchers and engineers from the Google Brain team within Google’s AI organization, it comes with strong support for machine learning and deep learning and the flexible numerical computation core is used across many other scientific domains.