Running Electrum in Python from the CLI on Ubuntu 20

In summary, the main issue is with running electrum on a computer with the latest version 4.0.9. The first odd problem is that python3 needs to be typed before electrum in order to get a response. This is due to the electrum folder containing a 'logging.py' file which is being imported instead of the logging module from the Python standard library. On the other hand, the computer with version 4.0.4 does not have this issue. The suggested solution is to specify a folder or create an alias for the first computer. However, there may be other problems to address.
  • #1
jack action
Science Advisor
Insights Author
Gold Member
2023 Award
3,097
7,628
I'm trying to run electrum (written in python) from the command line on Ubuntu 20. I have 2 similar computers. The first one has version 4.0.4 and once in the electrum folder, I type electrum (the name of the executable file) and it executes whatever command I ask for.

My problem is with my other computer - which has the latest version 4.0.9 - where, first odd problem, I have to type python3 electrum to get a response. I even changed the header of the file from #!/usr/bin/env python3 to #!/usr/bin/python3, still need to call python3 first (and the file is executable).

But the worst part is that it fails to run. I get this backtrace:

Code:
  File "electrum", line 39, in <module>
    import asyncio
  File "/usr/lib/python3.8/asyncio/__init__.py", line 8, in <module>
    from .base_events import *
  File "/usr/lib/python3.8/asyncio/base_events.py", line 18, in <module>
    import concurrent.futures
  File "/usr/lib/python3.8/concurrent/futures/__init__.py", line 8, in <module>
    from concurrent.futures._base import (FIRST_COMPLETED,
  File "/usr/lib/python3.8/concurrent/futures/_base.py", line 7, in <module>
    import logging
  File "/root/Electrum-4.0.9/electrum/logging.py", line 15, in <module>
    class LogFormatterForFiles(logging.Formatter):
AttributeError: partially initialized module 'logging' has no attribute 'Formatter' (most likely due to a circular import)

I know what happen, but I don't understand why. (I'm a newbie with python) In the electrum folder there is a 'logging.py' and the import logging is clearly referring to a file in the 'python3.8' folder, but it chooses the local one instead (hence the circular import problem). I don't know what to do with that (specifiying a folder?), especially since it works fine on the other machine.

I'm tired and I would gladly accept any help.
 
Technology news on Phys.org
  • #2
jack action said:
I have to type python3 electrum to get a response.

If the directory containing the electrum file is not on your PATH, the shell won't be able to find it, even if it is marked as executable.

jack action said:
In the electrum folder there is a 'logging.py'

And Python always looks there first (i.e., in the directory where the script being executed is located) for a file to import, before any other location. That's why that file is getting imported instead of the Python standard library one.

jack action said:
it works fine on the other machine

Since you are running an older version of electrum on the other machine, my guess would be that that older version does not have a logging.py file in the electrum directory, so the Python standard library logging module gets imported.
 
  • Like
Likes jack action
  • #3
Got it, I created an alias on the first computer.

Now I have other problems, but at least I'm going further.
 

1. How do I install Electrum on Ubuntu 20?

To install Electrum on Ubuntu 20, you can use the following command in your terminal: sudo apt install electrum. This will install Electrum and all its dependencies on your system.

2. Can I run Electrum from the command line on Ubuntu 20?

Yes, you can run Electrum from the command line on Ubuntu 20. After installing Electrum, you can launch it from the terminal using the command electrum.

3. How do I open my Electrum wallet from the command line?

To open your Electrum wallet from the command line, you can use the command electrum open. This will prompt you to enter your wallet's password and then open your wallet in the Electrum GUI.

4. How can I create a new wallet using Electrum on Ubuntu 20?

To create a new wallet using Electrum on Ubuntu 20, you can use the command electrum create. This will prompt you to choose a wallet name and password, and then create a new wallet for you to use.

5. Is it possible to send and receive transactions using Electrum from the command line on Ubuntu 20?

Yes, it is possible to send and receive transactions using Electrum from the command line on Ubuntu 20. You can use the command electrum payto to send funds to a specific address, and the command electrum history to view your transaction history.

Similar threads

  • Programming and Computer Science
Replies
8
Views
871
  • Programming and Computer Science
Replies
3
Views
1K
  • Programming and Computer Science
Replies
4
Views
5K
  • Programming and Computer Science
Replies
8
Views
1K
  • Programming and Computer Science
Replies
14
Views
1K
  • Programming and Computer Science
Replies
2
Views
844
  • Programming and Computer Science
Replies
3
Views
1K
  • Programming and Computer Science
Replies
5
Views
9K
  • Programming and Computer Science
Replies
17
Views
4K
  • Programming and Computer Science
Replies
16
Views
3K
Back
Top