question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AttributeError: 'Context' object has no attribute 'hostpython'

See original GitHub issue

Running this on OS X 10.11.3 p4a apk --requirements=kivysdl2 --private /tmp/test --package=org.test.test--name="test" --version=0.1 --bootstrap=sdl2 --android_api 19

I get the following error:

[INFO]:    This python-for-android revamp is an experimental alpha release!
[INFO]:    It should work (mostly), but you may experience missing features or bugs.
[INFO]:    Will compile for the following archs: armeabi
[INFO]:    Found possible SDK dirs in buildozer dir: android-sdk-20, android-sdk-21
[INFO]:    Will attempt to use SDK at /Users/ben/.buildozer/android/platform/android-sdk-20
[WARNING]: This SDK lookup is intended for debug only, if you use python-for-android much you should probably maintain your own SDK download.
[INFO]:    Getting Android API version from user argument
[INFO]:    Available Android APIs are (19)
[INFO]:    Requested API target 19 is available, continuing.
[INFO]:    Found possible NDK dirs in buildozer dir: android-ndk-r9c, android-ndk-r9c-darwin-x86_64.tar.bz2
[INFO]:    Will attempt to use NDK at /Users/ben/.buildozer/android/platform/android-ndk-r9c
[WARNING]: This NDK lookup is intended for debug only, if you use python-for-android much you should probably maintain your own NDK download.
[INFO]:    Got NDK version from $ANDROIDNDKVER
[INFO]:    Got Android NDK version from the NDK dir: it is r9c
[INFO]:    Using Google NDK r9c
[INFO]:    Found virtualenv at /usr/local/bin/virtualenv-2.7
[INFO]:    ccache is missing, the build will not be optimized in the future.
[INFO]:    Found the following toolchain versions: ['4.6', '4.8', 'clang3.3']
[INFO]:    Picking the latest gcc toolchain, here 4.8
[WARNING]: Missing executable: libtoolize is not installed
[INFO]:    No existing dists meet the given requirements!
[INFO]:    No dist exists that meets your requirements, so one will be built.
[INFO]:    Bootstrap requires recipes ['sdl2', ('python2', 'python3crystax')]
[INFO]:    No recipe named kivysdl2; will attempt to install with pip
[INFO]:    Loaded recipe sdl2 (depends on [('python2', 'python3crystax'), 'sdl2_image', 'sdl2_mixer', 'sdl2_ttf'], conflicts ['sdl', 'pygame', 'pygame_bootstrap_components'])
[INFO]:    Loaded recipe sdl2_image (depends on [])
[INFO]:    Loaded recipe sdl2_mixer (depends on [])
[INFO]:    Loaded recipe sdl2_ttf (depends on [])
[INFO]:    Found multiple valid recipe sets:
[INFO]:        ['sdl2_image', 'sdl2_mixer', 'python2', 'sdl2_ttf', 'sdl2']
[INFO]:        ['sdl2_image', 'sdl2_mixer', 'python3crystax', 'sdl2_ttf', 'sdl2']
[INFO]:    Using the first of these: ['sdl2_image', 'sdl2_mixer', 'python2', 'sdl2_ttf', 'sdl2']
[INFO]:    The selected bootstrap is sdl2
[INFO]:    # Creating dist with sdl2 bootstrap
[INFO]:    Dist will have name unnamed_dist_3 and recipes (kivysdl2)
[INFO]:    -> running cp -r /usr/local/lib/python2.7/site-packages/pythonforandroid/bootstraps/sdl2/build /Users/ben/Libra...(and 77 more)
[INFO]:    -> directory context /Users/ben/Library/Application Support/python-for-android/build/bootstrap_builds/sdl2-python2
[INFO]:    <- directory context /private/tmp/test
[INFO]:    Recipe build order is ['python2', 'sdl2_image', 'sdl2_mixer', 'sdl2_ttf', 'sdl2']
[INFO]:    The requirements (kivysdl2) were not found as recipes, they will be installed with pip.
[INFO]:    # Downloading recipes
[INFO]:    Downloading python2
[INFO]:    -> running mkdir -p /Users/ben/Library/Application Support/python-for-android/packages/python2
[INFO]:    -> directory context /Users/ben/Library/Application Support/python-for-android/packages/python2
[INFO]:    -> running basename http://python.org/ftp/python/2.7.2/Python-2.7.2.tar.bz2
[INFO]:    python2 download already cached, skipping
[WARNING]: Should check headers here! Skipping for now.
[INFO]:    <- directory context /private/tmp/test
[INFO]:    Downloading sdl2_image
[INFO]:    -> running mkdir -p /Users/ben/Library/Application Support/python-for-android/packages/sdl2_image
[INFO]:    -> directory context /Users/ben/Library/Application Support/python-for-android/packages/sdl2_image
[INFO]:    -> running basename https://www.libsdl.org/projects/SDL_image/release/SDL2_image-2.0.0.tar.gz
[INFO]:    sdl2_image download already cached, skipping
[WARNING]: Should check headers here! Skipping for now.
[INFO]:    <- directory context /private/tmp/test
[INFO]:    Downloading sdl2_mixer
[INFO]:    -> running mkdir -p /Users/ben/Library/Application Support/python-for-android/packages/sdl2_mixer
[INFO]:    -> directory context /Users/ben/Library/Application Support/python-for-android/packages/sdl2_mixer
[INFO]:    -> running basename https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-2.0.0.tar.gz
[INFO]:    sdl2_mixer download already cached, skipping
[WARNING]: Should check headers here! Skipping for now.
[INFO]:    <- directory context /private/tmp/test
[INFO]:    Downloading sdl2_ttf
[INFO]:    -> running mkdir -p /Users/ben/Library/Application Support/python-for-android/packages/sdl2_ttf
[INFO]:    -> directory context /Users/ben/Library/Application Support/python-for-android/packages/sdl2_ttf
[INFO]:    -> running basename https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-2.0.12.tar.gz
[INFO]:    sdl2_ttf download already cached, skipping
[WARNING]: Should check headers here! Skipping for now.
[INFO]:    <- directory context /private/tmp/test
[INFO]:    Downloading sdl2
[INFO]:    -> running mkdir -p /Users/ben/Library/Application Support/python-for-android/packages/sdl2
[INFO]:    -> directory context /Users/ben/Library/Application Support/python-for-android/packages/sdl2
[INFO]:    -> running basename https://www.libsdl.org/release/SDL2-2.0.3.tar.gz
[INFO]:    sdl2 download already cached, skipping
[WARNING]: Should check headers here! Skipping for now.
[INFO]:    <- directory context /private/tmp/test
[INFO]:    # Building all recipes for arch armeabi
[INFO]:    # Unpacking recipes
[INFO]:    Unpacking python2 for armeabi
[INFO]:    -> running basename http://python.org/ftp/python/2.7.2/Python-2.7.2.tar.bz2
[INFO]:    -> directory context /Users/ben/Library/Application Support/python-for-android/build/other_builds/python2/armeabi
[INFO]:    python2 is already unpacked, skipping
[INFO]:    <- directory context /private/tmp/test
[INFO]:    Unpacking sdl2_image for armeabi
[INFO]:    -> running basename https://www.libsdl.org/projects/SDL_image/release/SDL2_image-2.0.0.tar.gz
[INFO]:    -> directory context /Users/ben/Library/Application Support/python-for-android/build/bootstrap_builds/sdl2-python2/jni
[INFO]:    sdl2_image is already unpacked, skipping
[INFO]:    <- directory context /private/tmp/test
[INFO]:    Unpacking sdl2_mixer for armeabi
[INFO]:    -> running basename https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-2.0.0.tar.gz
[INFO]:    -> directory context /Users/ben/Library/Application Support/python-for-android/build/bootstrap_builds/sdl2-python2/jni
[INFO]:    sdl2_mixer is already unpacked, skipping
[INFO]:    <- directory context /private/tmp/test
[INFO]:    Unpacking sdl2_ttf for armeabi
[INFO]:    -> running basename https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-2.0.12.tar.gz
[INFO]:    -> directory context /Users/ben/Library/Application Support/python-for-android/build/bootstrap_builds/sdl2-python2/jni
[INFO]:    sdl2_ttf is already unpacked, skipping
[INFO]:    <- directory context /private/tmp/test
[INFO]:    Unpacking sdl2 for armeabi
[INFO]:    -> running basename https://www.libsdl.org/release/SDL2-2.0.3.tar.gz
[INFO]:    -> directory context /Users/ben/Library/Application Support/python-for-android/build/bootstrap_builds/sdl2-python2/jni
[INFO]:    sdl2 is already unpacked, skipping
[INFO]:    <- directory context /private/tmp/test
[INFO]:    # Prebuilding recipes
[INFO]:    Prebuilding python2 for armeabi
[INFO]:    python2 has no prebuild_armeabi, skipping
[INFO]:    Applying patches for python2[armeabi]
[INFO]:    python2 already patched, skipping
[INFO]:    Prebuilding sdl2_image for armeabi
[INFO]:    sdl2_image has no prebuild_armeabi, skipping
[INFO]:    Applying patches for sdl2_image[armeabi]
[INFO]:    sdl2_image already patched, skipping
[INFO]:    Prebuilding sdl2_mixer for armeabi
[INFO]:    sdl2_mixer has no prebuild_armeabi, skipping
[INFO]:    Applying patches for sdl2_mixer[armeabi]
[INFO]:    sdl2_mixer already patched, skipping
[INFO]:    Prebuilding sdl2_ttf for armeabi
[INFO]:    sdl2_ttf has no prebuild_armeabi, skipping
[INFO]:    Prebuilding sdl2 for armeabi
[INFO]:    sdl2 has no prebuild_armeabi, skipping
[INFO]:    Applying patches for sdl2[armeabi]
[INFO]:    sdl2 already patched, skipping
[INFO]:    # Building recipes
[INFO]:    Building python2 for armeabi
Traceback (most recent call last):
  File "/usr/local/bin/p4a", line 9, in <module>
    load_entry_point('python-for-android==0.3', 'console_scripts', 'p4a')()
  File "/usr/local/lib/python2.7/site-packages/pythonforandroid/toolchain.py", line 708, in main
    ToolchainCL()
  File "/usr/local/lib/python2.7/site-packages/pythonforandroid/toolchain.py", line 323, in __init__
    getattr(self, args.command)(unknown)
  File "/usr/local/lib/python2.7/site-packages/pythonforandroid/toolchain.py", line 105, in wrapper_func
    build_dist_from_args(ctx, dist, dist_args)
  File "/usr/local/lib/python2.7/site-packages/pythonforandroid/toolchain.py", line 142, in build_dist_from_args
    build_recipes(build_order, python_modules, ctx)
  File "/usr/local/lib/python2.7/site-packages/pythonforandroid/build.py", line 551, in build_recipes
    recipe.build_arch(arch)
  File "/usr/local/lib/python2.7/site-packages/pythonforandroid/recipes/python2/__init__.py", line 44, in build_arch
    self.do_python_build(arch)
  File "/usr/local/lib/python2.7/site-packages/pythonforandroid/recipes/python2/__init__.py", line 76, in do_python_build
    shprint(sh.cp, self.ctx.hostpython, self.get_build_dir(arch.arch))
AttributeError: 'Context' object has no attribute 'hostpython'

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

12reactions
inclementcommented, Feb 3, 2016

I think this relates to a known bug where the hostpython recipe is not included. You can work around it by adding hostpython2 to the requirements.

Also, don’t use kivysdl2 recipe, the name is just kivy.

1reaction
Zen-CODEcommented, Feb 19, 2016

Can confirm that adding ‘hostpython2’ in requirements solved this for me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

AttributeError: 'Context' object has no attribute 'hostpython ...
First attempt to deploy a simple kivy/python3 android app. Linux kali-Alien 4.9.0-kali4-amd64 #1 SMP Debian 4.9.30-2kali1 (2017-06-22) ...
Read more >
Kivy Buildozer AttributeError: 'Context' object has no attribute ...
This arises from a bug in the new python-for-android toolchain (which the android_new buildozer target uses).
Read more >
Script to export gltf fails with 'Context' object has no attribute ...
Creating a fake active object attribute on the context and passing it to the operator should work. Try this: CONVERT_DIR = "my/dir" import ......
Read more >
buildozer 'Context' object has no attribute 'hostpython'?
I have uninstalled and reinstalled buildozer but still can't get it to work on some ... AttributeError: 'Context' object has no attribute 'hostpython'...
Read more >
buildozer - PyPI
CalledProcessError: Command '['ant', 'debug']' returned non-zero exit status 1 #373; AttributeError: 'Context' object has no attribute 'hostpython' in ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found