discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

R: R: Cannot run a command


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
EasyLog 5 BetaTester
EasyLog PDA BetaTester
WinBollet BetaTester
D.C.I. CheckPoint Regione Campania
Skype: ik8ozv8520





      *********************************

      ******   GSM  +39 328 7110193  ******

      *****     SMS  +39 328 7110193    *****

      *********************************

 

Da: Chris Gorman <chrisjohgorman@gmail.com>
Inviato: domenica 6 settembre 2020 19:45
A: Vincenzo Mone <vimone@alice.it>
Oggetto: Re: R: Cannot run a command

 

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
import urllib2
chris [ ~ ]$ 2to3 -w python2script.py
RefactoringTool: Skipping optional fixer: buffer
RefactoringTool: Skipping optional fixer: idioms
RefactoringTool: Skipping optional fixer: set_literal
RefactoringTool: Skipping optional fixer: ws_comma
RefactoringTool: Refactored python2script.py
--- python2script.py (original)
+++ python2script.py (refactored)
@@ -1 +1 @@
-import urllib2
+import urllib.request, urllib.error, urllib.parse
RefactoringTool: Files that were modified:
RefactoringTool: python2script.py
chris [ ~ ]$ cat python2script.py
import urllib.request, urllib.error, urllib.parse
chris [ ~ ]$ cat python2script.py.bak
import urllib2

 

Now running all the scripts under python2 and python3, to help explain.

 

chris [ ~ ]$ python2 python2script.py.bak
chris [ ~ ]$ python3 python2script.py.bak
Traceback (most recent call last):
  File "python2script.py.bak", line 1, in <module>

    import urllib2

ModuleNotFoundError: No module named 'urllib2'

chris [ ~ ]$ python2 python2script.py

Traceback (most recent call last):
  File "python2script.py", line 1, in <module>
    import urllib.request, urllib.error, urllib.parse
ImportError: No module named request
chris [ ~ ]$ python3 python2script.py

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:

Hi Chris,

first thanks for coming back to my help request.

I state that I'm not good in Linux

Honestly I have already tried to use that site but did not get any success,

Maybe because I did not understood what to do.

I try to follow again the site and let you know what I do and the results:

 

I have opened Terminal and gave the following command:

 

import urllib2.request

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.

 

Nothing happened but I see the mouse pointer change in a cross

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.

Then I gave the second command:

 

response = urllib2.urlopen("http://www.google.com")

 

also here nothing happened so I carry on with the third command:

 

html = response.read()

 

also here nothing happened so I carry on with the fourth command:

 

print(html)

 

also here nothing happened.

Now what to do?

Actually I am stuck like this

 

 

 

Thanks

 

 

 

73’s de Enzo IK8OZV

EasyLog 5 BetaTester

EasyLog PDA BetaTester

WinBollet BetaTester

D.C.I. CheckPoint Regione Campania

Skype: ik8ozv8520

 

Hope this email helps.

 

Chris

 

 

 

      *********************************

      ******   GSM  +39 328 7110193  ******

      *****     SMS  +39 328 7110193    *****

      *********************************

 

> -----Messaggio originale-----

> Da: Chris Gorman <chrisjohgorman@gmail.com>

> Inviato: domenica 6 settembre 2020 18:25

> A: Vincenzo Mone <vimone@alice.it>

> Oggetto: Re: R: Cannot run a command

>

> On Sun, Sep 6, 2020 at 11:50 AM Vincenzo Mone <vimone@alice.it> wrote:

> >

> > Please anybody out there available to help me to solve my problem?

> > If yes please should we continue on this thread or start from the beginner

> using this thread.

> > Or start a new thread?

> > Thanks

> >

> Hi Vincenzo,

>

> I'm not an expert, but I will try to help you get your program loaded and

> running.  You should be using python3 not python2.  Python2 ended it's

> development cycle on Jan 1, 2020.  It is no longer maintained.

> If I understand your error from python3, you are unable to import urllib2.

> This is because urllib2 has been renamed urllib in Python3.

> (See https://stackoverflow.com/questions/2792650/import-error-no-

> module-name-urllib2

> .)  I would try running '2to3' on your script or manually editing the script,

> renaming the 'import urllib2' to 'import urllib'.  Best of luck and let me know

> how it goes once you make the changes.

>

> Chris

> > > >>>

> > > >>>    File

> > > >>> "/home/enzo/gr-lilacsat-pyqt5/examples/BY70-2/DSLWP-Downlink-

> > > >> Proxy/mun

> > > >>> _downlink_proxy.py",

> > > >>> line 29, in <module>

> > > >>>

> > > >>>      import urllib2

> > > >>>

> > > >>> ModuleNotFoundError: No module named 'urllib2'

> > > >>>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]