|
From: | Vincenzo Mone |
Subject: | R: R: Cannot run a command |
Date: | Sun, 6 Sep 2020 20:12:57 +0200 |
Thank s Chris for your help. As I said before I am not so clever on the Linux so you have to drive me by hand Like a little child when he goes to the school for the first time Lol. BTW I have tried as you said with the command: 2to3 -w /home/enzo/gr-lilacsat-pyqt5/examples/BY70-2/DSLWP-Downlink-Proxy/mun_downlink_proxy.py But as I do I not had the program I got: Command "2to3" not found, but can be installed with: sudo apt install 2to3 so I have installed it with the above suggested command and ran again the 2to3 command and got: Command "2to3" not found, but can be installed with: sudo apt install 2to3 RefactoringTool: Skipping optional fixer: buffer RefactoringTool: Skipping optional fixer: idioms RefactoringTool: Skipping optional fixer: set_literal RefactoringTool: Skipping optional fixer: ws_comma RefactoringTool: Refactored /home/enzo/gr-lilacsat-pyqt5/examples/BY70-2/DSLWP-Downlink-Proxy/mun_downlink_proxy.py --- /home/enzo/gr-lilacsat-pyqt5/examples/BY70-2/DSLWP-Downlink-Proxy/mun_downlink_proxy.py (original) +++ /home/enzo/gr-lilacsat-pyqt5/examples/BY70-2/DSLWP-Downlink-Proxy/mun_downlink_proxy.py (refactored) @@ -26,7 +26,7 @@ import datetime import xml.dom.minidom as minidom import pickle -import urllib2 +import urllib.request, urllib.error, urllib.parse from PyQt5 import QtGui, QtCore, Qt, QtWidgets # import ui confige @@ -296,7 +296,7 @@ f.close() self.reload() except Exception as error: - print("[File] Configured file read failed. Error: " + str(error)) + print(("[File] Configured file read failed. Error: " + str(error))) def reload(self): ''' @@ -593,7 +593,7 @@ Exception: an error occured accessing tle file or grc_param.py """ try: - f = urllib2.urlopen(str(self.ui.tle_url_text.text())) + f = urllib.request.urlopen(str(self.ui.tle_url_text.text())) tle = f.read() tle = tle.split("\n") @@ -641,13 +641,13 @@ log += "%02X" % ord(i) + " " count += 1 self.log_dict[index].write("Data: " + log + "\n\n") - print( + print(( "[Data] Received time is " + datetime.datetime.utcfromtimestamp( float(data['proxy_receive_time']/1000)).strftime( - '%Y-%m-%d %H:%M:%S')) - print( - "Data is: " + log + "\n" + "Data Length is: " + str(count)) + '%Y-%m-%d %H:%M:%S'))) + print(( + "Data is: " + log + "\n" + "Data Length is: " + str(count))) self.log_dict[index].flush() def normal_output_written(self, text): RefactoringTool: Files that were modified: RefactoringTool: /home/enzo/gr-lilacsat-pyqt5/examples/BY70-2/DSLWP-Downlink-Proxy/mun_downlink_proxy.py Then I have tried to run again my command: python2 ~/gr-lilacsat-pyqt5/examples/BY70-2/DSLWP-Downlink-Proxy/mun_downlink_proxy.py and got: Traceback (most recent call last): File "/home/enzo/gr-lilacsat-pyqt5/examples/BY70-2/DSLWP-Downlink-Proxy/mun_downlink_proxy.py", line 29, in <module> import urllib.request, urllib.error, urllib.parse ImportError: No module named request If I run python3…………… Instead of python2……. I get: Traceback (most recent call last): File "/home/enzo/gr-lilacsat-pyqt5/examples/BY70-2/DSLWP-Downlink-Proxy/mun_downlink_proxy.py", line 38, in <module> from core.data import server_data File "/home/enzo/gr-lilacsat-pyqt5/examples/BY70-2/DSLWP-Downlink-Proxy/core/data.py", line 2, in <module> import Queue ModuleNotFoundError: No module named 'Queue' Thanks 73’s de Enzo IK8OZV ****** GSM +39 328 7110193 ****** ***** SMS +39 328 7110193 ***** ********************************* Da: Chris Gorman <chrisjohgorman@gmail.com> Hi Vincenzo, No problem on the help. You should say you are not good in Linux yet. :) I'll try to explain as best I can. The import commands you are trying to run in the terminal need to be interpreted by python. So you would open a terminal and type python3, then hit enter and then try to import the module. What you have attempted to do is have the bash shell interpret python commands, which it won't do. Your python script you are trying to get running has a line in it import urllib2. This module existed in python2, but has been renamed in python3. My best advice is to run 2to3, which is a program to convert python scripts from python2 to python3, on your script. (Alternatively, you can edit the script in a text editor, changing urllib2 to urllib. I suggest 2to3 as it may catch more of the syntax changes than your urllib2. So open your terminal again and run ... (assuming I have the correct file here) 2to3 -w /home/enzo/gr-lilacsat-pyqt5/examples/BY70-2/DSLWP-Downlink-Proxy/mun_downlink_proxy.py The 2to3 program will make a backup file, /home/enzo/gr-lilacsat-pyqt5/examples/BY70-2/DSLWP-Downlink-Proxy/mun_downlink_proxy.py.bak, without the changes and change the file /home/enzo/gr-lilacsat-pyqt5/examples/BY70-2/DSLWP-Downlink-Proxy/mun_downlink_proxy.py to run under python3. Unfortunately 2to3 is not foolproof and there are some necessary changes it may miss. I haven't much experience using it myself, but it is the tool I recommend to change your python2 script to run under python3. As an example from my machine... chris [ ~ ]$ cat python2script.py Now running all the scripts under python2 and python3, to help explain. chris [ ~ ]$ python2 python2script.py.bak import urllib2 ModuleNotFoundError: No module named 'urllib2' chris [ ~ ]$ python2 python2script.py Traceback (most recent call last): As you can see one of the error messages is exactly what you are getting with your script. On Sun, Sep 6, 2020 at 12:50 PM Vincenzo Mone <vimone@alice.it> wrote:
This command is passed on to the bash shell from your terminal. It must have meaning to the shell as it locks my machine when I run it.
I get the same result you do here. I have to change to a virtual terminal and kill the process to get my mouse pointer back. Sorry.
Hope this email helps. Chris
|
[Prev in Thread] | Current Thread | [Next in Thread] |