Measurement Computing   Easy to Use | Easy to Integrate | Easy to Support catalog banner

Importing Python for Windows example programs into an IDE

Expand / Collapse
 

Importing Python for Windows example programs into an IDE


Importing Python for Windows example programs into an IDE
Python for Windows example programs can be imported into any IDE that supports Python, such as Eclipse (Neon and later) or Visual Studio (2015 and later).  Before performing the following steps, install the MCC UL Python API for Windows. 
1. Download the examples from the mcculw GitHub page at github.com/mccdaq. 
2. Create a new folder and unzip the examples to the folder location. For this example, the programs are unzipped to C:\Users\Public\Documents\Measurement Computing\DAQ\Python
3. Perform the following procedures to import the example programs into Eclipse or Visual Studio. 

Importing the Python for Windows example programs into Eclipse with PyDev 
Eclipse Neon.3 – Eclipse IDE for Java Developers required. Other versions of Eclipse will be similar. These instructions assume you have already installed Eclipse.
1. Open an Eclipse workspace; close the Welcome page if it opens. 
2. Install the PyDev plugin if it is not already installed: 
a. Go to Help»Install New Software; the Install dialog box opens. 
b. Click Add, and enter http://pydev.org/updates. 
c. Select all of the items listed, and follow the prompts to install. 
3. Right click in the Package Explorer, and go to New»Project.
The New Project dialog box opens.


4. Open the PyDev folder, select PyDev Project, and click Next



5. Enter a name for the new project, such as mcculw examples in the Project name texbox. 
6. Under the Project contents area, uncheck Use default and specify the directory where the examples were unzipped, typically C:\Users\Public\Documents\Measurement Computing\DAQ\Python. This path must be exact, since a Python namespace is directly tied to the directory structure. 
7. If you haven't done so already, configure the interpreter by clicking the link provided. 
a. Select PyDev»Interpreter»Python Interpreter
b. Click New
c. Enter a name for this interpreter, such as Python
d. Browse to the python executable (python.exe) installed on your system, and click OK.
The necessary files are added to the path. 
e. Apply the changes. 
8. Click Finish to complete the process. 

Running the examples
Follow the procedure below to run console-based examples or user interfaced-based Python for Windows example programs.
1. In the PyDev Package Explorer, expand either examples\console or examples\ui folder. 
2. Right click on the example you wish to run, hover over Debug As and select Python Run
3. After running the example once, subsequent runs may be performed by clicking on the Debug button on the toolbar, or by pressing the F11 key on the keyboard. 

Importing the Python for Windows example programs into Visual Studio with Python Tools for Visual Studio (PTVS)
The following instructions are intended for Visual Studio 2017. Other versions of Visual Studio should be similar. These instructions assume you have already installed Visual Studio 2017 with the PTVS.
1. Open Visual Studio, and select File»New»Project.
The New Project dialog box opens.



2. Select Python
3. Select From Existing Python code
4. Enter a name for the project, such as mcculw examples. 
5. In the Location text box, enter the directory where the examples were unzipped, typically C:\Users\Public\Documents\Measurement Computing\DAQ\Python, and click OK. This path must be exact, since Python namespaces are directly tied to the directory structure.
The Create New Project from Existing Python Code Wizard dialog box opens.




6. Click Finish to complete the wizard. 
7. In the Solution Explorer, right click on Search Paths, select …, add the directory where the Python examples were unzipped (typically C:\Users\Public\Documents\Measurement Computing\DAQ\Python), and click Select Folder

Running the examples
User-interface-based examples and console-based examples are installed. Perform the rollowing procedure to run an examply program.
1. From the Solution Explorer, expand either the examples\console or examples\ui folder. 
2. Right click on the example you wish to run and choose Set as Startup File
3. Run the selected example by pressing the Start button on the standard toolbar, or the F5 key on the keyboard. 




Rate this Article:
Tags:

Add Your Comments


For comments email TechSupport@mccdaq.com.

Details
Article ID: 50716

Last Modified:8/10/2017 9:18:56 AM

Article has been viewed 3,264 times.

Options