|
|
(One intermediate revision by one other user not shown) |
Line 1: |
Line 1: |
| [[Category:Language]]{{NoTitle}} | | #REDIRECT [[Language - Python]] |
| {|
| |
| |style="vertical-align:middle; width: 60%;"|
| |
| <font size=6>'''Language - Python'''
| |
| | |
| '''Windows with PyCharm'''</font>
| |
| | |
| Welcome to using Phidgets with Python! By using Python, you will have access to the complete Phidget22 API, including events.
| |
| | |
| PyCharm is an integrated development environment for Python by JetBrains.
| |
| | |
| |{{TOC limit|2}}
| |
| |}
| |
| | |
| {{Language_-_Python_Intro_Windows|
| |
| <tabber>
| |
| PIP=
| |
| The recommended way to install the '''Phidget22 Python module''' is using the '''PIP package manager'''.
| |
| <br><br>
| |
| You can install the Phidget22 libraries for your current PyCharm project with PIP by opening '''File > Settings'''
| |
| [[File:PyCharm_Settings.png|link=|center|800px]]
| |
| <br><br>
| |
| Next, navigate to '''Project > Project Interpreter''' and click on the + symbol located on the right hand side:
| |
| [[File:PyCharm_Interpreter.png|link=|center|800px]]
| |
| <br><br>
| |
| Type Phidget22 into the search bar, select the package named '''Phidget22''' and click Install Package:
| |
| [[File:PyCharm_Install_Phidget22.png|link=|center|800px]]
| |
| |-|
| |
| PIP Global=
| |
| The recommended way to install the '''Phidget22 Python module''' is using the '''PIP package manager'''.
| |
| <br><br>
| |
| Python versions '''2.7.9+''' and '''3.4+''' include PIP by default.
| |
| | |
| To install the Phidget22 Python module with PIP, simply open the '''Command Prompt''' (press the Windows key and search for "cmd"), and enter the command:
| |
| <syntaxhighlight lang=python>
| |
| python -m pip install Phidget22
| |
| </syntaxhighlight>
| |
| | |
| To install the Phidget22 libraries to a specific Python version, you can use the '''Python Windows Launcher''' from the Command Prompt as follows (replace -X.X with your Python version, e.g. -2.7 or -3.6):
| |
| <syntaxhighlight lang=python>
| |
| py -X.X -m pip install Phidget22
| |
| </syntaxhighlight>
| |
| | |
| To use the global Phidget22 library in your PyCharm project, select '''Inherit global site-packages''' when creating a new project.
| |
| | |
| [[File:PyCharm_Inherit_Global_Packages.png|center|link=]]
| |
| |-|
| |
| Manual Install=
| |
| To install the Phidget22 Python module without PIP, you will need to download the [{{SERVER}}/downloads/phidget22/libraries/any/Phidget22Python.zip Phidget22 Python module].
| |
| | |
| After unpacking the Phidget22 Python module, open the '''Command Prompt''' (press the Windows key and search for "cmd") Locate the folder where you downloaded the Python module and enter the following command:
| |
| <syntaxhighlight lang=python>
| |
| python setup.py install
| |
| </syntaxhighlight>
| |
| | |
| This will build the module and install the Python module files into your site-packages directory.
| |
| | |
| [[File:Python_install.png|link=|center]]
| |
| </tabber>
| |
| }}
| |
| | |
| {{Finding Code Samples|Python}}
| |
| | |
| ==Using the Code Samples==
| |
| | |
| Click the '''Download Example''' button to download a Java file with the sample code:
| |
| | |
| [[Image:Python_Sample_Code_Download.png|link=|center|border|800px]]
| |
| | |
| | |
| Add the example you just downloaded by dragging it into the project:
| |
| | |
| [[Image:Python_pycharm_import.png|link=|center|850px]]
| |
| | |
| | |
| Finally, run the project:
| |
| [[Image:Python_pycharm_run.png|link=|center|850px]]
| |
| | |
| | |
| If prompted, select the example file to be run:
| |
| [[Image:Python_pycharm_select_python_file.png|link=|center|850px]]
| |
| | |
| | |
| The project is now running with Phidgets!
| |
| | |
| {{Language Page What's Next}}
| |