Python 3.4.3 and sockets



  • Have anyone gotten sockets to work on the omega?

    Running something like

    import socket
    import encodings.idna
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    host = socket.gethostname()
    port = 9999
    s.bind((host, port))
    

    Throws the error

    Traceback (most recent call last):
      File "server3.py", line 2, in <module>
        import encodings.idna
      File "/usr/lib/python3.4/encodings/idna.py", line 3, in <module>
        import stringprep, re, codecs
      File "/usr/lib/python3.4/stringprep.py", line 8, in <module>
        from unicodedata import ucd_3_2_0 as unicodedata
    ImportError: No module named 'unicodedata'
    

    Google'in "unicodedata" afaik only gives me pre python3 results....

    Any ideas?



  • I receive a very different error.

    root@Omega-09E9:/proc# oupgrade -version

    Device Firmware Version: 0.0.6 b26

    root@Omega-09E9:~/test# python3 --version

    Python 3.4.3

    root@Omega-09E9:~/test# cat test.py
    import socket
    import encodings.idna
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    host = socket.gethostname()
    port = 9999
    s.bind((host, port))

    root@Omega-09E9:~/test# python3 test.py
    Traceback (most recent call last):
    File "prova.py", line 6, in <module>
    s.bind((host, port))
    socket.gaierror: [Errno -2] Name or service not known

    In my case the error is caused by the fact that the hostname cannot be resolved by any DNS.

    A simple solution is adding it to /etc/hosts.

    root@Omega-09E9:~/test# cat /etc/hosts
    127.0.0.1 localhost
    127.0.0.1 Omega-09E9



  • @Jarl-U-Christian-Persson It's worth to say that I'm using external USB storage [1] to install all the python3 modules available[2][3] through opkg [4].
    May be you are missing some modules? double check it.

    [1] https://wiki.onion.io/Tutorials/Using-USB-Storage-as-Rootfs - "option extroot with pivot-overlay"

    [2] List all the python3 packages available in the repository:

    opkg find '* python3 *' (remove the spaces before and after the *)

    [3] List of all the python3 packages installed:

    opkg list-installed | grep python3

    [4] https://wiki.openwrt.org/doc/techref/opkg



  • Until I get within reach of my Omega I can say that, the hostname is changed and it's python3-light.

    Update

    Packages found

    python3-base - 3.4.3-2
    python3-light - 3.4.3-2



  • A far as I can tell it was due to me running "python-light", installed the full python3 on a external usb as suggested and that fixed it.

    Copied the output from installing python3, in case someone wants to dig into what the cause might be.

    root@Omega-225A:/# opkg install python3
    Installing python3 (3.4.3-2) to root...
    Downloading http://downloads.openwrt.org/chaos_calmer/15.05/ar71xx/generic/packages/packages/python3_3.4.3-2_ar71xx.ipk.
    Installing python3-light (3.4.3-2) to root...
    Downloading http://downloads.openwrt.org/chaos_calmer/15.05/ar71xx/generic/packages/packages/python3-light_3.4.3-2_ar71xx.ipk.
    Installing python3-base (3.4.3-2) to root...
    Downloading http://downloads.openwrt.org/chaos_calmer/15.05/ar71xx/generic/packages/packages/python3-base_3.4.3-2_ar71xx.ipk.
    Installing libffi (3.0.13-1) to root...
    Downloading http://downloads.openwrt.org/chaos_calmer/15.05/ar71xx/generic/packages/packages/libffi_3.0.13-1_ar71xx.ipk.
    Installing libbz2 (1.0.6-2) to root...
    Downloading http://downloads.openwrt.org/chaos_calmer/15.05/ar71xx/generic/packages/base/libbz2_1.0.6-2_ar71xx.ipk.
    Installing python3-asyncio (3.4.3-2) to root...
    Downloading http://downloads.openwrt.org/chaos_calmer/15.05/ar71xx/generic/packages/packages/python3-asyncio_3.4.3-2_ar71xx.ipk.
    Installing python3-codecs (3.4.3-2) to root...
    Downloading http://downloads.openwrt.org/chaos_calmer/15.05/ar71xx/generic/packages/packages/python3-codecs_3.4.3-2_ar71xx.ipk.
    Installing python3-ctypes (3.4.3-2) to root...
    Downloading http://downloads.openwrt.org/chaos_calmer/15.05/ar71xx/generic/packages/packages/python3-ctypes_3.4.3-2_ar71xx.ipk.
    Installing python3-dbm (3.4.3-2) to root...
    Downloading http://downloads.openwrt.org/chaos_calmer/15.05/ar71xx/generic/packages/packages/python3-dbm_3.4.3-2_ar71xx.ipk.
    Installing libdb47 (4.7.25.4.NC-4.1) to root...
    Downloading http://downloads.openwrt.org/chaos_calmer/15.05/ar71xx/generic/packages/packages/libdb47_4.7.25.4.NC-4.1_ar71xx.ipk.
    Installing libxml2 (2.9.2-3) to root...
    Downloading http://downloads.openwrt.org/chaos_calmer/15.05/ar71xx/generic/packages/packages/libxml2_2.9.2-3_ar71xx.ipk.
    Installing python3-decimal (3.4.3-2) to root...
    Downloading http://downloads.openwrt.org/chaos_calmer/15.05/ar71xx/generic/packages/packages/python3-decimal_3.4.3-2_ar71xx.ipk.
    Installing python3-distutils (3.4.3-2) to root...
    Downloading http://downloads.openwrt.org/chaos_calmer/15.05/ar71xx/generic/packages/packages/python3-distutils_3.4.3-2_ar71xx.ipk.
    Installing python3-email (3.4.3-2) to root...
    Downloading http://downloads.openwrt.org/chaos_calmer/15.05/ar71xx/generic/packages/packages/python3-email_3.4.3-2_ar71xx.ipk.
    Installing python3-gdbm (3.4.3-2) to root...
    Downloading http://downloads.openwrt.org/chaos_calmer/15.05/ar71xx/generic/packages/packages/python3-gdbm_3.4.3-2_ar71xx.ipk.
    Installing libgdbm (1.11-1) to root...
    Downloading http://downloads.openwrt.org/chaos_calmer/15.05/ar71xx/generic/packages/packages/libgdbm_1.11-1_ar71xx.ipk.
    Installing python3-logging (3.4.3-2) to root...
    Downloading http://downloads.openwrt.org/chaos_calmer/15.05/ar71xx/generic/packages/packages/python3-logging_3.4.3-2_ar71xx.ipk.
    Installing python3-lzma (3.4.3-2) to root...
    Downloading http://downloads.openwrt.org/chaos_calmer/15.05/ar71xx/generic/packages/packages/python3-lzma_3.4.3-2_ar71xx.ipk.
    Installing liblzma (5.2.1-2) to root...
    Downloading http://downloads.openwrt.org/chaos_calmer/15.05/ar71xx/generic/packages/packages/liblzma_5.2.1-2_ar71xx.ipk.
    Installing python3-multiprocessing (3.4.3-2) to root...
    Downloading http://downloads.openwrt.org/chaos_calmer/15.05/ar71xx/generic/packages/packages/python3-multiprocessing_3.4.3-2_ar71xx.ipk.
    Installing python3-ncurses (3.4.3-2) to root...
    Downloading http://downloads.openwrt.org/chaos_calmer/15.05/ar71xx/generic/packages/packages/python3-ncurses_3.4.3-2_ar71xx.ipk.
    Installing python3-openssl (3.4.3-2) to root...
    Downloading http://downloads.openwrt.org/chaos_calmer/15.05/ar71xx/generic/packages/packages/python3-openssl_3.4.3-2_ar71xx.ipk.
    Installing python3-pydoc (3.4.3-2) to root...
    Downloading http://downloads.openwrt.org/chaos_calmer/15.05/ar71xx/generic/packages/packages/python3-pydoc_3.4.3-2_ar71xx.ipk.
    Installing python3-sqlite3 (3.4.3-2) to root...
    Downloading http://downloads.openwrt.org/chaos_calmer/15.05/ar71xx/generic/packages/packages/python3-sqlite3_3.4.3-2_ar71xx.ipk.
    Installing libsqlite3 (3081101-1) to root...
    Downloading http://downloads.openwrt.org/chaos_calmer/15.05/ar71xx/generic/packages/packages/libsqlite3_3081101-1_ar71xx.ipk.
    Installing python3-unittest (3.4.3-2) to root...
    Downloading http://downloads.openwrt.org/chaos_calmer/15.05/ar71xx/generic/packages/packages/python3-unittest_3.4.3-2_ar71xx.ipk.
    Installing python3-xml (3.4.3-2) to root...
    Downloading http://downloads.openwrt.org/chaos_calmer/15.05/ar71xx/generic/packages/packages/python3-xml_3.4.3-2_ar71xx.ipk.
    Configuring python3-base.
    Configuring libffi.
    Configuring libbz2.
    Configuring python3-light.
    Configuring python3-pydoc.
    Configuring liblzma.
    Configuring python3-email.
    Configuring python3-decimal.
    Configuring python3-xml.
    Configuring libxml2.
    Configuring python3-ncurses.
    Configuring python3-distutils.
    Configuring python3-codecs.
    Configuring python3-multiprocessing.
    Configuring python3-asyncio.
    Configuring python3-ctypes.
    Configuring libdb47.
    Configuring python3-dbm.
    Configuring libgdbm.
    Configuring python3-gdbm.
    Configuring python3-logging.
    Configuring python3-lzma.
    Configuring python3-openssl.
    Configuring libsqlite3.
    Configuring python3-sqlite3.
    Configuring python3-unittest.
    Configuring python3.
    

Log in to reply
 

Looks like your connection to Onion Community was lost, please wait while we try to reconnect.