basforge

Search titles, text and the “If it doesn’t work” cases.

    RU

    Python from scratch: install it and send files to your phone over Wi-Fi

    Install Python and, with one command, python -m http.server, open a computer folder to a phone on the same network: the phone shows a page listing the files, tap one and it downloads. No cable, no cloud, and no code of your own.

    You needThe terminal and cdRunning pythonModules and python -m

    What you end up with

    computer  ~/Pictures/trip               the folder you're sharing
              python -m http.server         a server on port 8000 while the window is open
    phone     http://192.168.1.23:8000      the file list; tap one and it downloads

    The server runs while the terminal is open: Ctrl+C and the folder is closed. There’s no password, so share only on your own network and only for the duration of the transfer.

    Step by step

    1. Install Python

      Where How Command
      Windows the Python install manager: Microsoft Store or python.org/downloads (it’s the same installer) python
      Ubuntu 24.04 already installed, Python 3.12 python3
      macOS the installer from python.org, or brew install python python3

      On Windows, the old .exe installer with the “Add python.exe to PATH” checkbox is deprecated since 3.14, and there won’t be one for 3.16. The install manager puts the python and py commands on the path itself — no checkboxes. After installing, open a new terminal window: the old one doesn’t know about the new commands.

      python --version
      # Python 3.15.1

      From here on, type python; on Ubuntu and macOS, python3.

    2. Go to the folder you’re sharing

      cd ~/Pictures/trip

      ~ is your home folder; paths with / work in PowerShell and in Linux and macOS terminals alike. The server shares the folder it’s started in, with everything inside. Don’t share your whole home folder: it holds .ssh keys, browser files and documents. Instead of cd you can use the -d option with a full path: python -m http.server -d D:\photos\trip. ~ won’t do here: Windows PowerShell 5.1 doesn’t expand it in program arguments, and Python gets it literally.

    3. Start the server

      python -m http.server
      # Serving HTTP on :: port 8000 (http://[::]:8000/) ...

      -m http.server runs the http.server module from the standard library as a program. A module is a file of Python code; the standard library is the modules that come with Python, so there’s nothing to download. :: in the output means the server listens on all the computer’s addresses, IPv4 included; the default port is 8000.

      On Windows, the firewall asks on first launch whether to let Python onto the network. Tick “Private networks”; public ones aren’t needed.

    4. Find the computer’s network address

      Where Command What to look for
      Windows ipconfig the IPv4 line in the Wi-Fi or Ethernet block
      Ubuntu hostname -I the first address
      macOS ipconfig getifaddr en0 the Wi-Fi address

      Home addresses start with 192.168., 10. or 172.16.–172.31.. Addresses from the WSL, Hyper-V and VirtualBox blocks aren’t visible to the phone.

    5. Open it from the phone

      The phone is on the same Wi-Fi as the computer. In the browser type http://192.168.1.23:8000: your own address, http rather than https, and the port after a colon. The “Directory listing for /” page shows the files and folders. Tap a file and the browser offers to download it. Images, PDFs and text (.txt, .md) it opens itself; text with non-ASCII characters may show up garbled — download such a file with a long press, “Download link”.

      The terminal prints a line for each request:

      192.168.1.57 - - [21/Oct/2026 23:05:30] "GET / HTTP/1.1" 200 -

      First comes the phone’s address; 200 means the file was served.

    6. Close it

      Ctrl+C in the server window prints Keyboard interrupt received, exiting., and the folder is no longer available.

    What’s new here

    • Running python. Python is an interpreter program: it reads code and executes it. python --version asks it for its version, and python file.py runs your own script — details in Running Python.
    • A module and python -m. http.server is a standard library module, and -m runs it by name without knowing where the file lives. python -m pip and python -m venv run the same way.

    Limits

    • One direction only. http.server serves files but can’t receive them: you can’t send from the phone to the computer this way.
    • No password and no encryption. Any device on the network sees the whole folder, hidden files included. The documentation marks the module as unsuitable for production: it has only basic security checks.
    • It listens on every address. To limit it to one, use -b: python -m http.server -b 192.168.1.23.

    If it doesn’t work

    You type python, and the Microsoft Store opens

    Cause
    Python isn’t installed, and Windows substitutes a stub — an app alias that leads to the store.
    Fix
    Install the Python install manager (step 1) and open a new terminal window. If that doesn’t help — “App execution aliases” in Start: the toggle for “Python (default)” should be on.

    Command 'python' not found, did you mean: command 'python3'

    Cause
    Ubuntu has Python 3, but the command is called python3; there’s no python without the digit by default.
    Fix
    Type python3 -m http.server. If you want python, sudo apt install python-is-python3.

    The phone loads for a long time and says the page can’t be opened

    Cause
    The computer’s firewall blocks incoming connections on port 8000, or the phone is on another network: guest Wi-Fi, mobile data.
    Fix
    On Windows, allow Python on “Private networks” (the prompt on first launch, or “Allow an app through Windows Firewall”); the Wi-Fi network must be set to “Private”. Put the phone on the same network as the computer, not the guest one.

    The address is typed in, but a foreign page or nothing opens

    Cause
    You took the address of the wrong adapter: WSL, Hyper-V and VirtualBox have their own addresses, which the phone can’t see.
    Fix
    In ipconfig, take the address from the Wi-Fi or Ethernet block the computer uses on the home network — usually 192.168.x.x.

    Started it in another folder, but the phone shows the old one

    Cause
    The first server is still running in another window. On Windows a second start on the same port gives no error — two processes share the port.
    Fix
    Stop the old one with Ctrl+C in its window, or start the new one on another port: python -m http.server 8080.

    Tapped a .md or .txt, and instead of a download you get text with garbled characters

    Cause
    The browser opens files it can display by itself. http.server serves them without an encoding (Content-Type: text/markdown, no charset=utf-8), and the browser reads non-ASCII text — accents, other alphabets — in the wrong encoding.
    Fix
    Long-press the file in the list and choose “Download link”: the file is saved as is, in UTF-8.

    How to check

    From the phone, open http://<computer address>:8000 — you see “Directory listing for /” and your files, and a line with the phone’s address and 200 appears in the terminal. After Ctrl+C the same page doesn’t open on the phone.