Python on the AXC 2152
Has anyone tried to dabble with using python on the AXC 2152?
What was the application and did you have any success?
Has anyone tried to dabble with using python on the AXC 2152?
What was the application and did you have any success?
Comments
Moved to PLCnext thread.
We've many requests regard Python and have it for evaluation on stack (Phoenix Contact Electronics Headquarter) but had unfortunately not time to do some tests.
Maybe someone else has already made experiences?
I tried Python with the AXC F 2152 mid-last year, at the start of the Early Adopter program.
One of our customers is investigating Machine Learning using Python, so I was hoping to install something like SciPy for them. The recommended installation method is to use pip (Python's standard package manager). But pip doesn't seem to be included with PLCnext. So I tried installing pip using the get-pip.py script. I ran into problems there with something I can't quite recall ... I do remember spending several hours installing a whole string of dependency packages by hand, but eventually I hit a dead-end. So I didn't get too far. I left it hoping that a future PLCnext firmware release would include pip, or at least that someone would find a way of installing it.
My Python skills only extend to a semester of lectures and assignments in college, so I may be missing something obvious.
- Martin.
Hi ngreene,
Basically Python3 is on the target. It greatly depends on which dependencies you are focussing on. Did you have anything in mind, if so, please let us know, so we can see if we can shed some light onto the way to get those deps going.Like scikitlearn, django, simplehttp, ...
Cheers
There was an idea thrown out here to use the USB-C port on the controller to control an LED strip. I'm thinking it could be programmed to flash in different colors/patterns using python.
This post was honestly just a soft question to see if anyone has had success with doing anything with it.
Maybe better use Lua? We had some success using it for our tasks.
Ledstrips are always nice, but i'm wondering, if you'll be able to run the Ledstrip via the USB-C port, I don't think you can use it for general purposes.
I'm not sure if the USB-C is general purpose either. Doesn't hurt to find out.
Hello,
similar question from my side: I would like to send MQTT packages via a python script and need MQTT libs. Is there any advice in the meantime, how to install pyhton packages? With pip/ensurepip I was not able to install...
Thanks in advance
Christof
Hello Christof,
Since my earlier post in this thread, I've discovered the ipkg package manager, and it looks like this can be used to help with python projects on the AXC F 2152.
Outline of the procedure you should try:
- Install ipkg package manager, following the procedure shown in this video.
- Use ipkg to install python27:
- Install pip (python package manager):
- Now use pip to install your mqtt package, for example:
==================================
Please give this a try and let us know how you get on.
- Martin.
Hello Martin,
great, that was the missing information. In general, I'm not a fan of videos, that's why I just have overseen this great and helpful explanation.
Thanks a lot. That's perfect.
Have a good holiday season.
Christof
Hi,
with Martin's help, I was able to make some steps forward. I was able
- to install ipkg
- to install pip3
- to install openSSL
- to install paho-mqtt
- to install AWSIoTPythonSDK
Where I struggle right now is running my python3 script, which should send some data via MQTT to an AWS Broker. The first line with an "import of json" fails ("no module named json").
Does somebody have a hint for me?
Best regards
Christof
Hi Christof,
Some of this answer will be speculation, because I didn't bring an AXC home with me for Christmas ...
I'm guessing that the version of Python 3 that is factory-installed on the AXC is a minimal version that doesn't include the required json module.
When you installed the py3-pip package using ipkg, I'm guessing it also installed python3 as a dependency, since ipkg doesn't realise that python 3 is on the PLC already. The version of python installed by ipkg (in the /opt/ directory, I think) may be the "complete" version that does include the json module you need. You didn't say what command you are using to start python, but you should make sure that the python you are starting is the one installed by ipkg (in the /opt/ directory), not the factory-installed python. You may want to update some sym-links to make this easier.
Hope this helps.
- Martin.
Hi Martin,
sorry for the late answer; I only have certain periods of time to follow up this project.
For me, you are the Hero of the Month. Your answer was completely right. Perfect.
With the other python in /opt/bin , my script is running now and I am able to send data from the PLCnext to the AWS IoT Platform. Great, that's really great.
Thanks a lot.
Super.
Christof
/opt/bin/ipkg install python3
done
/opt/bin/pip3 install --upgrade pip
Requirement already up-to-date: pip in /opt/lib/python3.7/site-packages (10.0.0)
Could not fetch URL https://pypi.python.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.python.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate is not yet valid (_ssl.c:1051)'))) - skipping
Cant upgrade pip
Please help.
root@axcf2152:~# ipkg install openssl
Package openssl (1.0.2n-1) installed in /opt/ is up to date.
I am trying to get the opcua package to install on the plc-Next.
I have used:
You can prevent the SSL certificate from occurring, by adding the following urls to the trusted hosts.