Error in Example - Build with Python

Run python3 example.py then this Error

┌──(venv)─(scalper㉿kali)-[~/Desktop/auction-demo]
└─$ python3 example.py                                            1 ⨯
Generating temporary accounts...
Traceback (most recent call last):
  File "/usr/lib/python3.9/urllib/request.py", line 1346, in do_open
    h.request(req.get_method(), req.selector, req.data, headers,
  File "/usr/lib/python3.9/http/client.py", line 1285, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.9/http/client.py", line 1331, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.9/http/client.py", line 1280, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.9/http/client.py", line 1040, in _send_output
    self.send(msg)
  File "/usr/lib/python3.9/http/client.py", line 980, in send
    self.connect()
  File "/usr/lib/python3.9/http/client.py", line 946, in connect
    self.sock = self._create_connection(
  File "/usr/lib/python3.9/socket.py", line 844, in create_connection
    raise err
  File "/usr/lib/python3.9/socket.py", line 832, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/scalper/Desktop/auction-demo/example.py", line 122, in <module>
    simple_auction()
  File "/home/scalper/Desktop/auction-demo/example.py", line 23, in simple_auction
    creator = getTemporaryAccount(client)
  File "/home/scalper/Desktop/auction-demo/auction/testing/resources.py", line 48, in getTemporaryAccount
    genesisAccounts = getGenesisAccounts()
  File "/home/scalper/Desktop/auction-demo/auction/testing/setup.py", line 36, in getGenesisAccounts
    wallets = kmd.list_wallets()
  File "/home/scalper/Desktop/auction-demo/venv/lib/python3.9/site-packages/algosdk/kmd.py", line 88, in list_wallets
    res = self.kmd_request("GET", req)
  File "/home/scalper/Desktop/auction-demo/venv/lib/python3.9/site-packages/algosdk/kmd.py", line 61, in kmd_request
    resp = urlopen(req)
  File "/usr/lib/python3.9/urllib/request.py", line 214, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.9/urllib/request.py", line 517, in open
    response = self._open(req, data)
  File "/usr/lib/python3.9/urllib/request.py", line 534, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
  File "/usr/lib/python3.9/urllib/request.py", line 494, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.9/urllib/request.py", line 1375, in http_open
    return self.do_open(http.client.HTTPConnection, req)
  File "/usr/lib/python3.9/urllib/request.py", line 1349, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [Errno 111] Connection refused>
           

hi dear please help me

Most likely the URL you gave to create the algod client is incorrect.

Can you show your code? (replace any secret token/key with “**”)
How do you connect to the network? There are 3 options explained there: Set up your development environment - Algorand Developer Portal

The code is the same as the tutorial example
https://developer.algorand.org/docs/get-started/dapps/pyteal/

In that case, most likely sandbox is not running properly.

Have you successfully run the step Build with Python - Algorand Developer Portal?

See also this thread Sandbox fails to complete initialization on testnet -- it doesn't even try to "fast-catchup." Can anybody help? - #2 by fabrice or any other post on forum that may talk about sandbox issues.

The output of the test is as follows
What do you think is the problem?

┌──(scalper㉿kali)-[~/Desktop/sandbox]
└─$ ./sandbox up testnet

Starting sandbox for: testnet
see sandbox.log for detailed progress, or use -v.
* started!

algod version
                                                                      
┌──(scalper㉿kali)-[~/Desktop/sandbox]
└─$ ./sandbox test                                                1 ⨯

Test command forwarding...
~$ docker exec -it algod uname -a

There is a bug somewhere, the output should contain much more information.
Please provide sandbox.log or run ./sandbox up testnet -v.

I’ve also opened an issue Improve output in case of error · Issue #103 · algorand/sandbox · GitHub that you can upvote to improve error handling.

┌──(scalper㉿kali)-[~/Desktop/sandbox]
└─$ sandbox.log
sandbox.log: command not found

┌──(scalper㉿kali)-[~/Desktop/sandbox]
└─$ ./sandbox up testnet -v. 127 ⨯

Starting sandbox for: testnet
see sandbox.log for detailed progress, or use -v.

  • started!

algod version

┌──(scalper㉿kali)-[~/Desktop/sandbox]
└─$ sandbox.log 1 ⨯
sandbox.log: command not found

In your opinion, Docker is not a problem
Why not make the container?

┌──(scalper㉿kali)-[~/Desktop/sandbox]
└─$ docker exec -it algod uname -a                              127 ⨯

Error: No such container: algod
                                                                      
┌──(scalper㉿kali)-[~/Desktop/sandbox]
└─$   

Docker installation was successful
So what is the problem?

┌──(scalper㉿kali)-[~/Desktop/sandbox]
└─$ docker run hello-world                                      130 ⨯

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

sandbox.log is a log text file. Please upload it e.g., on https://gist.github.com/ on give a link here.
It is not a command to run.

Please:

  • indicate your OS
  • indicate your Docker version
  • run the following commands and indicate the output
git rev-parse HEAD
git status
  • run the following commands and indicate the output:
./sandbox clean
./sandbox reset
./sandbox up testnet -v
  • Upload the sandbox.log at the end of that as indicated above.

My Linux-Kali operating system

┌──(scalper㉿kali)-[~/Desktop/auction-demo]
└─$ docker --version
Docker version 20.10.11+dfsg1, build dea9396
┌──(scalper㉿kali)-[~/Desktop/auction-demo]
└─$ git rev-parse HEAD     
407db6a5c0f90a47680c2fca5aaed26dc4592e8d
                                                                                
┌──(scalper㉿kali)-[~/Desktop/auction-demo]
└─$ git status             
On branch main
Your branch is up to date with 'origin/main'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)
	docker-compose-linux-x86_64.sha256

nothing added to commit but untracked files present (use "git add" to track)
                                                                                
┌──(scalper㉿kali)-[~/Desktop/auction-demo]
└─$ ./sandbox clean        

Cleaning up sandbox environment...
                                                                                
┌──(scalper㉿kali)-[~/Desktop/auction-demo]
└─$ ./sandbox reset        
No active sandbox to reset.
                                                                                
┌──(scalper㉿kali)-[~/Desktop/auction-demo]
└─$ ./sandbox up testnet -v                                                 1 ⨯

Starting sandbox for: testnet
.clean file found in sandbox directory. Rebuilding images...
* docker-compose build --no-cache
indexer-db uses an image, skipping
Building algod
Sending build context to Docker daemon  137.2kB
Step 1/24 : ARG GO_VERSION=1.17.5
Step 2/24 : FROM golang:$GO_VERSION
 ---> 276895edf967
Step 3/24 : ARG CHANNEL=nightly
 ---> Running in 16b6a54ea6e0
Removing intermediate container 16b6a54ea6e0
 ---> 157e06e19502
Step 4/24 : ARG URL=
 ---> Running in 11c4dd5bd267
Removing intermediate container 11c4dd5bd267
 ---> bb4f6626a9be
Step 5/24 : ARG BRANCH=
 ---> Running in f7e959678ef8
Removing intermediate container f7e959678ef8
 ---> 936ba5d8fabf
Step 6/24 : ARG SHA=
 ---> Running in 492928377a37
Removing intermediate container 492928377a37
 ---> 4f156155e1b4
Step 7/24 : ARG GENESIS_FILE=""
 ---> Running in c249677a5350
Removing intermediate container c249677a5350
 ---> 434fd1532364
Step 8/24 : ARG BOOTSTRAP_URL=""
 ---> Running in 1b58b9e9fcd2
Removing intermediate container 1b58b9e9fcd2
 ---> 9c39e6feb7f3
Step 9/24 : ARG ALGOD_PORT=""
 ---> Running in c83817e01174
Removing intermediate container c83817e01174
 ---> 8996b051b846
Step 10/24 : ARG KMD_PORT=""
 ---> Running in 4e931bb143a0
Removing intermediate container 4e931bb143a0
 ---> 08d82c886586
Step 11/24 : ARG TOKEN=""
 ---> Running in 112883cba799
Removing intermediate container 112883cba799
 ---> 173a222e8796
Step 12/24 : ARG TEMPLATE=""
 ---> Running in c597d1132776
Removing intermediate container c597d1132776
 ---> f4a4b0412811
Step 13/24 : RUN echo "Installing from source. ${URL} -- ${BRANCH}"
 ---> Running in b019bb7acfa9
Installing from source.  -- 
Removing intermediate container b019bb7acfa9
 ---> 87750e99bdca
Step 14/24 : ENV BIN_DIR="$HOME/node"
 ---> Running in 0a918a394d72
Removing intermediate container 0a918a394d72
 ---> fdf1333cbed4
Step 15/24 : ENV ALGORAND_DATA="/opt/data"
 ---> Running in 89d9321eab89
Removing intermediate container 89d9321eab89
 ---> 973db96f34ee
Step 16/24 : ENV HOME /opt
 ---> Running in 9182ba325c41
Removing intermediate container 9182ba325c41
 ---> c7621ba59af4
Step 17/24 : ENV DEBIAN_FRONTEND noninteractive
 ---> Running in ee6255b684c0
Removing intermediate container ee6255b684c0
 ---> 7c6dfb53f609
Step 18/24 : RUN apt-get update && apt-get install -y apt-utils curl git git-core bsdmainutils python3
 ---> Running in 20144587e000
Get:1 http://security.debian.org/debian-security bullseye-security InRelease [44.1 kB]
Get:2 http://deb.debian.org/debian bullseye InRelease [116 kB]
Get:3 http://deb.debian.org/debian bullseye-updates InRelease [39.4 kB]
Get:4 http://security.debian.org/debian-security bullseye-security/main amd64 Packages [119 kB]
Get:5 http://deb.debian.org/debian bullseye/main amd64 Packages [8183 kB]
Get:6 http://deb.debian.org/debian bullseye-updates/main amd64 Packages [2596 B]
Fetched 8504 kB in 27s (311 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
curl is already the newest version (7.74.0-1.3+deb11u1).
git is already the newest version (1:2.30.2-1).
python3 is already the newest version (3.9.2-3).
python3 set to manually installed.
The following additional packages will be installed:
  bsdextrautils ncal
Suggested packages:
  calendar whois vacation mailutils
The following NEW packages will be installed:
  apt-utils bsdextrautils bsdmainutils ncal
0 upgraded, 4 newly installed, 0 to remove and 9 not upgraded.
Need to get 631 kB of archives.
After this operation, 1682 kB of additional disk space will be used.
Get:1 http://deb.debian.org/debian bullseye/main amd64 apt-utils amd64 2.2.4 [439 kB]
Get:2 http://security.debian.org/debian-security bullseye-security/main amd64 bsdextrautils amd64 2.36.1-8+deb11u1 [145 kB]
Get:3 http://deb.debian.org/debian bullseye/main amd64 ncal amd64 12.1.7+nmu3 [30.1 kB]
Get:4 http://deb.debian.org/debian bullseye/main amd64 bsdmainutils all 12.1.7+nmu3 [16.4 kB]
debconf: delaying package configuration, since apt-utils is not installed
Fetched 631 kB in 2s (312 kB/s)
Selecting previously unselected package bsdextrautils.
(Reading database ... 15709 files and directories currently installed.)
Preparing to unpack .../bsdextrautils_2.36.1-8+deb11u1_amd64.deb ...
Unpacking bsdextrautils (2.36.1-8+deb11u1) ...
Selecting previously unselected package apt-utils.
Preparing to unpack .../apt-utils_2.2.4_amd64.deb ...
Unpacking apt-utils (2.2.4) ...
Selecting previously unselected package ncal.
Preparing to unpack .../ncal_12.1.7+nmu3_amd64.deb ...
Unpacking ncal (12.1.7+nmu3) ...
Selecting previously unselected package bsdmainutils.
Preparing to unpack .../bsdmainutils_12.1.7+nmu3_all.deb ...
Unpacking bsdmainutils (12.1.7+nmu3) ...
Setting up apt-utils (2.2.4) ...
Setting up bsdextrautils (2.36.1-8+deb11u1) ...
update-alternatives: using /usr/bin/write.ul to provide /usr/bin/write (write) in auto mode
Setting up ncal (12.1.7+nmu3) ...
Setting up bsdmainutils (12.1.7+nmu3) ...
Removing intermediate container 20144587e000
 ---> fcac620635b6
Step 19/24 : COPY . /tmp
 ---> 6e81e3981803
Step 20/24 : RUN /tmp/images/algod/install.sh     -d "${BIN_DIR}"     -c "${CHANNEL}"     -u "${URL}"     -b "${BRANCH}"     -s "${SHA}"
 ---> Running in 342d371007f1
/tmp/images/algod /go
Installing algod with options:
  BINDIR = /node
  CHANNEL = stable
  URL = 
  BRANCH = 
  SHA = 
Current Version = 0
updater
updater binary was downloaded
Latest Version = 12885032963
New version found
Checking for files matching: 'channel/stable/node_stable_linux-amd64_' in bucket algorand-releases
Update Downloaded to /tmp/tmp.rtryqjmNky/12885032963.tar.gz
Expanding update...
Validating update...
Starting the new update script to complete the installation...
... Resuming installation from the latest update script
Current Version = 0
Backing up current binary files...
Backing up current data files from /node/data...
Installing new binary files...
Installing new data files into /node/data...
Copying genesis files locally
Checking for new ledger in /node/data
Cannot read genesis file /node/data/genesis.json: open /node/data/genesis.json: no such file or directory
Updating genesis files for default network
New genesis ID, resetting wallets
New Ledger - restoring genesis accounts in /node/data
New Ledger - importing rootkeys for genesis accounts
Imported 0 keys
Applying migration fixups...
Deleting existing log files in /node/data
Install complete - restart node manually
Removing intermediate container 342d371007f1
 ---> e50842d7347b
Step 21/24 : RUN /tmp/images/algod/setup.py  --bin-dir "$BIN_DIR"  --data-dir "/opt/data"  --start-script "/opt/start_algod.sh"  --network-dir "/opt/testnetwork"  --network-template "//tmp/${TEMPLATE}"  --network-token "${TOKEN}"  --algod-port "${ALGOD_PORT}"  --kmd-port "${KMD_PORT}"  --bootstrap-url "${BOOTSTRAP_URL}"  --genesis-file "/tmp/${GENESIS_FILE}"
 ---> Running in c21875d5d17f
Configuring network with the following arguments:
{   'algod_port': '4001',
    'bin_dir': '/node',
    'bootstrap_url': '<network>.algorand.network',
    'data_dir': '/opt/data',
    'genesis_file': '/tmp/genesis/testnet/genesis.json',
    'kmd_port': '4002',
    'network_dir': '/opt/testnetwork',
    'network_template': '//tmp/images/algod/template.json',
    'network_token': 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
    'start_script': '/opt/start_algod.sh'}
Setting up real retwork.
Start commands for /opt/start_algod.sh:
[   '/node/goal node start -d /opt/testnetwork/Node',
    '/node/kmd start -t 0 -d /opt/testnetwork/Node/kmd-v0.5']
Creating symlink /opt/data -> /opt/testnetwork/Node
Removing intermediate container c21875d5d17f
 ---> 696984569761
Step 22/24 : ENV PATH="$BIN_DIR:${PATH}"
 ---> Running in ee349b16c29a
Removing intermediate container ee349b16c29a
 ---> cf31e694a7bc
Step 23/24 : WORKDIR /opt/data
 ---> Running in 53fc50f7c128
Removing intermediate container 53fc50f7c128
 ---> 8781a6d628f8
Step 24/24 : CMD ["/opt/start_algod.sh"]
 ---> Running in ab20497cd4ef
Removing intermediate container ab20497cd4ef
 ---> cc01f4bb4f28
[Warning] One or more build-args [CDT_PORT] were not consumed
Successfully built cc01f4bb4f28
Successfully tagged sandbox_algod:latest
Building indexer
Sending build context to Docker daemon  137.2kB
Step 1/14 : ARG GO_VERSION=1.17.5
Step 2/14 : FROM golang:$GO_VERSION-alpine
 ---> d8bf44a3f6b4
Step 3/14 : ARG URL=https://github.com/algorand/indexer
 ---> Running in 4662f9862dfa
Removing intermediate container 4662f9862dfa
 ---> 79d30638e04d
Step 4/14 : ARG BRANCH=master
 ---> Running in 2e691d575b73
Removing intermediate container 2e691d575b73
 ---> 7c98a6ade3cc
Step 5/14 : ARG SHA=""
 ---> Running in 42b09a1c2c6a
Removing intermediate container 42b09a1c2c6a
 ---> b25bdbff46bb
Step 6/14 : ENV HOME /opt/indexer
 ---> Running in db6fb70202f1
Removing intermediate container db6fb70202f1
 ---> bccfc6029d55
Step 7/14 : WORKDIR /opt/indexer
 ---> Running in f00e662de67c
Removing intermediate container f00e662de67c
 ---> c0b8bc8376ab
Step 8/14 : ENV DEBIAN_FRONTEND noninteractive
 ---> Running in 90ca99ff0e14
Removing intermediate container 90ca99ff0e14
 ---> bb0e7fc24ad7
Step 9/14 : RUN apk add --no-cache git bzip2 make bash libtool boost-dev autoconf automake g++
 ---> Running in 42f9b2a92a83
fetch https://dl-cdn.alpinelinux.org/alpine/v3.15/main/x86_64/APKINDEX.tar.gz
^CERROR: Aborting.

./sandbox log

┌──(scalper㉿kali)-[~/Desktop/auction-demo]
└─$ ./sandbox log                                                                                                                                                  127 ⨯
sandbox commands:
  up    [config]  -> start the sandbox environment.
  down            -> tear down the sandbox environment.
  reset           -> reset the containers to their initial state.
  clean           -> stops and deletes containers and data directory.
  test            -> runs some tests to demonstrate usage.
  enter [algod||indexer||indexer-db]
                  -> enter the sandbox container.
  version         -> print binary versions.
  copyTo <file>   -> copy <file> into the algod. Useful for offline transactions, offline LogicSigs & TEAL work.
  copyFrom <file> -> copy <file> from the algod. Useful for offline transactions, offline LogicSigs & TEAL work.

algorand commands:
  logs        -> stream algorand logs with the carpenter utility.
  status      -> get node status.
  goal (args) -> run goal command like 'goal node status'.

special flags for 'up' command:
  -v|--verbose           -> display verbose output when starting standbox.
  -s|--skip-fast-catchup -> skip catchup when connecting to real network.
  -i|--interactive       -> start docker-compose in interactive mode.

The simplest is to switch to Ubuntu 20.04 I think.

Now, I see at the end:

^CERROR: Aborting.

Did you Ctrl+C ./sandbox up testnet -v?
If not, is it possible that something is limiting your Internet access?
Are you using a proxy? Are you using Tor? Are you using a limited Internet connection?

Hello my dear friend
Changing the operating system to Ubuntu did not solve the problem
Solved by changing the operating system DNS
Grateful

┌──(venv)─(scalper㉿kali)-[~/Desktop/auction-demo]
└─$ python3 example.py 
Generating temporary accounts...
Alice (seller account): GQWSLYREYFSSQIC5TAX3OW6NPTMDATJTX6HOWW6PODKD33PD3QYNLP3AWU
Bob (auction creator account): EA2ZHTOPHI7ACOTGQNAVE2O4V6HQF5OGQMG3ZMHQTCO2MO2SMXAFJGTNZI
Carla (bidder account) GLMXXTP6Y2MWXQZQ2DCUHWJA4PV4AMA7EVOGCO3NZDNRW37I2FXS22MOCI 

Alice is generating an example NFT...
The NFT ID is 17
Alice's balances: {0: 99999000, 17: 1} 

Bob is creating an auction that lasts 30 seconds to auction off the NFT...
Done. The auction app ID is 18 and the escrow account is TYLKPGKW3Q2XA3WRE4VILV3SAJXBC2OIK37RMBO52Q6K4MAPMXKVXLNFCM 

Alice is setting up and funding NFT auction...
Done

Alice's balances: {0: 99998000, 17: 0}
Auction escrow balances: {0: 202000, 17: 1} 

Carla wants to bid on NFT, her balances: {0: 100000000}
Carla is placing bid for 1000000 microAlgos
Carla is opting into NFT with ID 17
Done

Waiting 17 seconds for the auction to finish

Alice is closing out the auction

The auction escrow now holds the following: {0: 0}
Alice's balances after auction:  {0: 101197000, 17: 0}  Algos
Carla's balances after auction:  {0: 98997000, 17: 1}  Algos

1 Like

Good to know it’s fixed.
Indeed, limited ISP DNS may cause issues.