i've a sort of issue with python3 pip or hmac during buildozer compiling process.
The error says 'xrange is not defined', but this happen only if I compile on a previous buildozer folder (.buildozer).
If I make a clean build removing the .buildozer folder it works as expected and also the .apk works good.
I have already added 'xrange = range' in my main.py
Any help will be appreciated. Thanx in advance.
This is the complete buildozer error:
[INFO]: *** PYTHON PACKAGE / PROJECT INSTALL STAGE ***
[INFO]: The requirements (kivy-garden.qrcode, kivy-garden.xcamera, kivy-garden.zbarcam, unix-time) don't have recipes, attempting to install them with pip
[INFO]: If this fails, it may mean that the module has compiled components and needs a recipe.
[INFO]: -> directory context /home/ciko/Scrivania/bitCodePro-App/.buildozer/android/platform/build-armeabi-v7a/build
[INFO]: -> running python3 -m venv venv
[INFO]: Upgrade pip to latest version
[INFO]: -> running bash -c source venv/bin/activate && pip install -U pip
Exception in thread background thread for pid 27840:
Traceback (most recent call last):
File "/usr/lib/python3.7/threading.py", line 926, in _bootstrap_inner
self.run()
File "/usr/lib/python3.7/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/home/ciko/.local/lib/python3.7/site-packages/sh.py", line 1633, in wrap
fn(*rgs, **kwargs)
File "/home/ciko/.local/lib/python3.7/site-packages/sh.py", line 2557, in background_thread
handle_exit_code(exit_code)
File "/home/ciko/.local/lib/python3.7/site-packages/sh.py", line 2261, in fn
return self.command.handle_command_exit_code(exit_code)
File "/home/ciko/.local/lib/python3.7/site-packages/sh.py", line 861, in handle_command_exit_code
raise exc
sh.ErrorReturnCode_1:
RAN: /bin/bash -c 'source venv/bin/activate && pip install -U pip'
STDOUT:
Traceback (most recent call last):
File "/home/ciko/Scrivania/bitCodePro-App/.buildozer/android/platform/build-armeabi-v7a/build/venv/bin/pip", line 10, in <module>
sys.exit(main())
File "/home/ciko/Scrivania/bitCodePro-App/.buildozer/android/platform/build-armeabi-v7a/build/venv/lib/python3.7/site-packages/pip/_internal/cli/main.py", line 73, in main
command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
File "/home/ciko/Scrivania/bitCodePro-App/.buildozer/android/platform/build-armeabi-v7a/build/venv/lib/python3.7/site-packages/pip/_internal/commands/__init__.py", line 105, in create_command
module = importlib.import_module(module_path)
File "/home/ciko/Scrivania/bitCodePro-App/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/hostpython3/desktop/hostpython3/Lib/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/ciko/Scrivania/bitCodePro-App/.buildozer/android/platform/build-armeabi-v7a/build/venv/lib/python3.7/site-packages/pip/_internal/commands/install.py", line 17, in <module>
from pip._internal.cli.req_command import RequirementCommand, with_cleanup
File "/home/ciko/Scrivania/bitCodePro-App/.buildozer/android/platform/build-armeabi-v7a/build/venv/lib/python3.7/site-packages/pip/_internal/cli/req_command.py", line 18, in <module>
from pip._internal.index.collector import LinkCollector
File "/home/ciko/Scrivania/bitCodePro-App/.buildozer/android/platform/build-armeabi-v7a/build/venv/lib/python3.7/site-packages/pip/_internal/index/collector.py", line 14, in <module>
from pip._vendor import html5lib, requests
File "/home/ciko/Scrivania/bitCodePro-App/.buildozer/android/platform/build-armeabi-v7a/build/venv/lib/python3.7/site-packages/pip/_vendor/requests/__init__.py", line 43, in <module>
from pip._vendor import urllib3
File "/home/ciko/Scrivania/bitCodePro-App/.buildozer/android/platform/build-armeabi-v7a/build/venv/lib/python3.7/site-packages/pip/_vendor/urllib3/__init__.py", line 13, in <module>
from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool, connection_from_url
File "/home/ciko/Scrivania/bitCodePro-App/.buildozer/android/platform/build-armeabi-v7a/build/venv/lib/python3.7/site-packages/pip/_vendor/urllib3/connectionpool.py", line 11, in <module>
from .connection import (
File "/home/ciko/Scrivania/bitCodePro-App/.buildozer/android/platform/build-armeabi-v7a/build/venv/lib/python3.7/site-packages/pip/_vendor/urllib3/connection.py", line 15, in <module>
from .util.proxy import create_proxy_ssl_context
File "/home/ciko/Scrivania/bitCodePro-App/.buildozer/android/platform/build-armeabi-v7a/build/venv/lib/python3.7/site-packages/pip/_vendor/urllib3/util/__init__.py", line 8, in <module>
from .ssl_ import (
File "/home/ciko/Scrivania/bitCodePro-App/.buildozer/android/platform/build-armeabi-v7a/build/venv/lib/python3.7/site-packages/pip/_vendor/urllib3/util/ssl_.py", line 3, in <module>
import hmac
File "/home/ciko/Scrivania/bitCodePro-App/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/bitcodepro/hmac.py", line 8, in <module>
trans_5C = "".join ([chr (x ^ 0x5C) for x in xrange(256)])
NameError: name 'xrange' is not defined
STDERR:
Traceback (most recent call last):
File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/ciko/Scrivania/bitCodePro-App/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 1231, in <module>
main()
File "/home/ciko/Scrivania/bitCodePro-App/.buildozer/android/platform/python-for-android/pythonforandroid/entrypoints.py", line 18, in main
ToolchainCL()
File "/home/ciko/Scrivania/bitCodePro-App/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 688, in __init__
getattr(self, command)(args)
File "/home/ciko/Scrivania/bitCodePro-App/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 154, in wrapper_func
build_dist_from_args(ctx, dist, args)
File "/home/ciko/Scrivania/bitCodePro-App/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 208, in build_dist_from_args
args, "ignore_setup_py", False
File "/home/ciko/Scrivania/bitCodePro-App/.buildozer/android/platform/python-for-android/pythonforandroid/build.py", line 598, in build_recipes
ignore_setup_py=ignore_project_setup_py
File "/home/ciko/Scrivania/bitCodePro-App/.buildozer/android/platform/python-for-android/pythonforandroid/build.py", line 772, in run_pymodules_install
), _env=copy.copy(base_env))
File "/home/ciko/Scrivania/bitCodePro-App/.buildozer/android/platform/python-for-android/pythonforandroid/logger.py", line 167, in shprint
for line in output:
File "/home/ciko/.local/lib/python3.7/site-packages/sh.py", line 907, in next
self.wait()
File "/home/ciko/.local/lib/python3.7/site-packages/sh.py", line 837, in wait
self.handle_command_exit_code(exit_code)
File "/home/ciko/.local/lib/python3.7/site-packages/sh.py", line 861, in handle_command_exit_code
raise exc
sh.ErrorReturnCode_1:
RAN: /bin/bash -c 'source venv/bin/activate && pip install -U pip'
STDOUT:
Traceback (most recent call last):
File "/home/ciko/Scrivania/bitCodePro-App/.buildozer/android/platform/build-armeabi-v7a/build/venv/bin/pip", line 10, in <module>
sys.exit(main())
File "/home/ciko/Scrivania/bitCodePro-App/.buildozer/android/platform/build-armeabi-v7a/build/venv/lib/python3.7/site-packages/pip/_internal/cli/main.py", line 73, in main
command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
File "/home/ciko/Scrivania/bitCodePro-App/.buildozer/android/platform/build-armeabi-v7a/build/venv/lib/python3.7/site-packages/pip/_internal/commands/__init__.py", line 105, in create_command
module = importlib.import_module(module_path)
File "/home/ciko/Scrivania/bitCodePro-App/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/hostpython3/desktop/hostpython3/Lib/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/ciko/Scrivania/bitCodePro-App/.buildozer/android/platform/build-armeabi-v7a/build/venv/lib/python3.7/site-packages/pip/_internal/commands/install.py", line 17, in <module>
from pip._internal.cli.req_command import RequirementCommand, with_cleanup
File "/home/ciko/Scrivania/bitCodePro-App/.buildozer/android/platform/build-armeabi-v7a/build/venv/lib/python3.7/site-packages/pip/_internal/cli/req_command.py", line 18, in <module>
from pip._internal.index.collector import LinkCollector
File "/home/ciko/Scrivania/bitCodePro-App/.buildozer/android/platform/build-armeabi-v7a/build/venv/lib/python3.7/site-packages/pip/_internal/index/collector.py", line 14, in <module>
from pip._vendor import html5lib, requests
File "/home/ciko/Scrivania/bitCodePro-App/.buildozer/android/platform/build-armeabi-v7a/build/venv/lib/python3.7/site-packages/pip/_vendor/requests/__init__.py", line 43, in <module>
from pip._vendor import urllib3
File "/home/ciko/Scrivania/bitCodePro-App/.buildozer/android/platform/build-armeabi-v7a/build/venv/lib/python3.7/site-packages/pip/_vendor/urllib3/__init__.py", line 13, in <module>
from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool, connection_from_url
File "/home/ciko/Scrivania/bitCodePro-App/.buildozer/android/platform/build-armeabi-v7a/build/venv/lib/python3.7/site-packages/pip/_vendor/urllib3/connectionpool.py", line 11, in <module>
from .connection import (
File "/home/ciko/Scrivania/bitCodePro-App/.buildozer/android/platform/build-armeabi-v7a/build/venv/lib/python3.7/site-packages/pip/_vendor/urllib3/connection.py", line 15, in <module>
from .util.proxy import create_proxy_ssl_context
File "/home/ciko/Scrivania/bitCodePro-App/.buildozer/android/platform/build-armeabi-v7a/build/venv/lib/python3.7/site-packages/pip/_vendor/urllib3/util/__init__.py", line 8, in <module>
from .ssl_ import (
File "/home/ciko/Scrivania/bitCodePro-App/.buildozer/android/platform/build-armeabi-v7a/build/venv/lib/python3.7/site-packages/pip/_vendor/urllib3/util/ssl_.py", line 3, in <module>
import hmac
File "/home/ciko/Scrivania/bitCodePro-App/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/bitcodepro/hmac.py", line 8, in <module>
trans_5C = "".join ([chr (x ^ 0x5C) for x in xrange(256)])
NameError: name 'xrange' is not defined
Edit:
The issue is with hmac because it's made for python2.
The problem is in hmac.py at lines 8 and 9:
trans_5C = "".join ([chr (x ^ 0x5C) for x in xrange(256)])
^
trans_36 = "".join ([chr (x ^ 0x36) for x in xrange(256)])
^
in python3 'xrange' has been removed and replaced by 'range'. So i'm trying to add 'xrange = range' in my main.py but it works only with buildozer clean build process and not if .buildozer folder is already present, even if I build a new .apk, it works on the clean build but fails during the 2nd build.
Surfing the net i founded a different way to solve the issue by downloading 'future' package via pip and adding the following line to the main.py
from past.builtins import xrange
but as i said, it works on clean build and fails during the following one.
My target is to not make a clean build every time because the process is too long. Any idea?
I have the solution!
Remove 'hmac' from buildozer.spec requirements;
Download official python3.7 hmac.py from here
Put the hmac.py into your buildozer folder maybe in a dedicated subfolder called i.e. 'my_pkgs' and import it directly from your main.py in this way:
from my_pkgs import hmac
It works perfectly during the first clean build and also for all other builds released with the same .buildozer folder.
Exactly what i'm searching for.
[SOLVED] by me!
Related
I'm having trouble with pip on my Windows 10 system. If I try to do anything with pip (such as "pip -h") I get the following:
D:\Downloads\pip\pip-22.0.4>pip -h
Traceback (most recent call last):
File "C:\Program Files\Python310\Scripts\pip-script.py", line 33, in <module>
sys.exit(load_entry_point('pip==22.0.4', 'console_scripts', 'pip')())
File "C:\Program Files\Python310\Scripts\pip-script.py", line 25, in importlib_load_entry_point
return next(matches).load()
File "C:\Program Files\Python310\lib\importlib\metadata\__init__.py", line 171, in load
module = import_module(match.group('module'))
File "C:\Program Files\Python310\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "C:\Users\jxcla\AppData\Local\Programs\Python\Python39\Lib\site-packages\pip\_internal\cli\main.py", line 9, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "C:\Users\jxcla\AppData\Local\Programs\Python\Python39\Lib\site-packages\pip\_internal\cli\autocompletion.py", line 10, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "C:\Users\jxcla\AppData\Local\Programs\Python\Python39\Lib\site-packages\pip\_internal\cli\main_parser.py", line 8, in <module>
from pip._internal.cli import cmdoptions
File "C:\Users\jxcla\AppData\Local\Programs\Python\Python39\Lib\site-packages\pip\_internal\cli\cmdoptions.py", line 23, in <module>
from pip._internal.cli.parser import ConfigOptionParser
File "C:\Users\jxcla\AppData\Local\Programs\Python\Python39\Lib\site-packages\pip\_internal\cli\parser.py", line 12, in <module>
from pip._internal.configuration import Configuration, ConfigurationError
File "C:\Users\jxcla\AppData\Local\Programs\Python\Python39\Lib\site-packages\pip\_internal\configuration.py", line 20, in <module>
from pip._internal.exceptions import (
File "C:\Users\jxcla\AppData\Local\Programs\Python\Python39\Lib\site-packages\pip\_internal\exceptions.py", line 14, in <module>
from pip._vendor.rich.console import Console, ConsoleOptions, RenderResult
File "C:\Users\jxcla\AppData\Local\Programs\Python\Python39\Lib\site-packages\pip\_vendor\rich\console.py", line 55, in <module>
from .pretty import Pretty, is_expandable
File "C:\Users\jxcla\AppData\Local\Programs\Python\Python39\Lib\site-packages\pip\_vendor\rich\pretty.py", line 366, in <module>
class Node:
File "C:\Users\jxcla\AppData\Local\Programs\Python\Python36\Lib\site-packages\dataclasses.py", line 958, in dataclass
return wrap(_cls)
File "C:\Users\jxcla\AppData\Local\Programs\Python\Python36\Lib\site-packages\dataclasses.py", line 950, in wrap
return _process_class(cls, init, repr, eq, order, unsafe_hash, frozen)
File "C:\Users\jxcla\AppData\Local\Programs\Python\Python36\Lib\site-packages\dataclasses.py", line 800, in _process_class
cls_fields = [_get_field(cls, name, type)
File "C:\Users\jxcla\AppData\Local\Programs\Python\Python36\Lib\site-packages\dataclasses.py", line 800, in <listcomp>
cls_fields = [_get_field(cls, name, type)
File "C:\Users\jxcla\AppData\Local\Programs\Python\Python36\Lib\site-packages\dataclasses.py", line 659, in _get_field
if (_is_classvar(a_type, typing)
File "C:\Users\jxcla\AppData\Local\Programs\Python\Python36\Lib\site-packages\dataclasses.py", line 550, in _is_classvar
return type(a_type) is typing._ClassVar
AttributeError: module 'typing' has no attribute '_ClassVar'. Did you mean: 'ClassVar'?
I'm not sure when this started happening and I've tried reinstalling pip in numerous ways, but no luck. Same error. I've searched for answers on the web, but nothing has fixed it for me.
I'm a bit of a noob when it comes to this, so it's entirely possible I've done something to gum up the works. Any help would be greatly appreciated.
John
This issue seems to be cropping up for me in a couple of my CI builds. One possible fix seems to be:
pip uninstall dataclasses -y
In my case, I don't know how dataclasses is getting installed (it's supposed to be a built-in not a dependency), but it failed last night when I unpinned the dependency scs.
I built a docker file that installs gdal and proj library on CentOS8.
After successfully installation of all dependencies, when i run my docker image i get OSError: libgdal.so.27: cannot open shared object file: No such file or directory.
Please how do i rectify this ?
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
File "/usr/lib64/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/usr/lib64/python3.6/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "/home/devuser/.local/lib/python3.6/site-packages/django/utils/autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "/home/devuser/.local/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 110, in inner_run
autoreload.raise_last_exception()
File "/home/devuser/.local/lib/python3.6/site-packages/django/utils/autoreload.py", line 76, in raise_last_exception
raise _exception[1]
File "/home/devuser/.local/lib/python3.6/site-packages/django/core/management/__init__.py", line 357, in execute
autoreload.check_errors(django.setup)()
File "/home/devuser/.local/lib/python3.6/site-packages/django/utils/autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "/home/devuser/.local/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/devuser/.local/lib/python3.6/site-packages/django/apps/registry.py", line 114, in populate
app_config.import_models()
File "/home/devuser/.local/lib/python3.6/site-packages/django/apps/config.py", line 211, in import_models
self.models_module = import_module(models_module_name)
File "/usr/lib64/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/auth/models.py", line 2, in <module>
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/auth/base_user.py", line 48, in <module>
class AbstractBaseUser(models.Model):
File "/home/devuser/.local/lib/python3.6/site-packages/django/db/models/base.py", line 122, in __new__
new_class.add_to_class('_meta', Options(meta, app_label))
File "/home/devuser/.local/lib/python3.6/site-packages/django/db/models/base.py", line 326, in add_to_class
value.contribute_to_class(cls, name)
File "/home/devuser/.local/lib/python3.6/site-packages/django/db/models/options.py", line 206, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
File "/home/devuser/.local/lib/python3.6/site-packages/django/db/__init__.py", line 28, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "/home/devuser/.local/lib/python3.6/site-packages/django/db/utils.py", line 214, in __getitem__
backend = load_backend(db['ENGINE'])
File "/home/devuser/.local/lib/python3.6/site-packages/django/db/utils.py", line 111, in load_backend
return import_module('%s.base' % backend_name)
File "/usr/lib64/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/gis/db/backends/postgis/base.py", line 6, in <module>
from .features import DatabaseFeatures
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/gis/db/backends/postgis/features.py", line 1, in <module>
from django.contrib.gis.db.backends.base.features import BaseSpatialFeatures
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/gis/db/backends/base/features.py", line 3, in <module>
from django.contrib.gis.db import models
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/gis/db/models/__init__.py", line 3, in <module>
import django.contrib.gis.db.models.functions # NOQA
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/gis/db/models/functions.py", line 3, in <module>
from django.contrib.gis.db.models.fields import BaseSpatialField, GeometryField
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/gis/db/models/fields.py", line 3, in <module>
from django.contrib.gis import forms, gdal
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/gis/forms/__init__.py", line 3, in <module>
from .fields import ( # NOQA
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/gis/forms/fields.py", line 2, in <module>
from django.contrib.gis.gdal import GDALException
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/gis/gdal/__init__.py", line 28, in <module>
from django.contrib.gis.gdal.datasource import DataSource
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/gis/gdal/datasource.py", line 39, in <module>
from django.contrib.gis.gdal.driver import Driver
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/gis/gdal/driver.py", line 5, in <module>
from django.contrib.gis.gdal.prototypes import ds as vcapi, raster as rcapi
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/gis/gdal/prototypes/ds.py", line 9, in <module>
from django.contrib.gis.gdal.libgdal import GDAL_VERSION, lgdal
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/gis/gdal/libgdal.py", line 50, in <module>
lgdal = CDLL(lib_path)
File "/usr/lib64/python3.6/ctypes/__init__.py", line 343, in __init__
self._handle = _dlopen(self._name, mode)
OSError: libgdal.so.27: cannot open shared object file: No such file or directory
What i've tried
DISCLAIMER: I really do not understand why i did all of these and i don't know what they mean. I just want to install gdal for geodjango
RUN echo /usr/local/lib >> /etc/ld.so.conf.d/usrlocal.conf
RUN touch /etc/ld.so.conf.d/libgdal-x86_64.conf
RUN echo "/usr/local/lib" >> /etc/ld.so.conf.d/libgdal-x86_64.conf
Django recommends doing this
RUN export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
I noticed that something was wrong when I first wanted to install the tqdm package for python3. Running pip install tqdm i revieved
ImportError: cannot import name 'ensure_str' from 'six' (/home/carl/.local/lib/python3.8/site-packages/six.py).
There seem to be a similar problem when running a variety of pip commands such as pip freeze and pip list, but not pip show [package] or pip -h.
I am unure where to start and what to make of the situation and would greatly appreciate help. I will post the full trace below for context.
Full traceback:
pip install [any package]
Traceback (most recent call last):
File "/usr/bin/pip", line 11, in <module>
load_entry_point('pip==20.0.2', 'console_scripts', 'pip')()
File "/usr/lib/python3.8/site-packages/pip/_internal/cli/main.py", line 73, in main
command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
File "/usr/lib/python3.8/site-packages/pip/_internal/commands/__init__.py", line 96, in create_command
module = importlib.import_module(module_path)
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/usr/lib/python3.8/site-packages/pip/_internal/commands/install.py", line 24, in <module>
from pip._internal.cli.req_command import RequirementCommand
File "/usr/lib/python3.8/site-packages/pip/_internal/cli/req_command.py", line 20, in <module>
from pip._internal.operations.prepare import RequirementPreparer
File "/usr/lib/python3.8/site-packages/pip/_internal/operations/prepare.py", line 16, in <module>
from pip._internal.distributions import (
File "/usr/lib/python3.8/site-packages/pip/_internal/distributions/__init__.py", line 2, in <module>
from pip._internal.distributions.wheel import WheelDistribution
File "/usr/lib/python3.8/site-packages/pip/_internal/distributions/wheel.py", line 5, in <module>
from pip._internal.utils.wheel import pkg_resources_distribution_for_wheel
File "/usr/lib/python3.8/site-packages/pip/_internal/utils/wheel.py", line 12, in <module>
from pip._vendor.six import PY2, ensure_str
ImportError: cannot import name 'ensure_str' from 'six' (/home/carl/.local/lib/python3.8/site-packages/six.py)
Traceback: pip freeze
Traceback (most recent call last):
File "/usr/bin/pip", line 11, in <module>
load_entry_point('pip==20.0.2', 'console_scripts', 'pip')()
File "/usr/lib/python3.8/site-packages/pip/_internal/cli/main.py", line 73, in main
command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
File "/usr/lib/python3.8/site-packages/pip/_internal/commands/__init__.py", line 96, in create_command
module = importlib.import_module(module_path)
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/usr/lib/python3.8/site-packages/pip/_internal/commands/freeze.py", line 12, in <module>
from pip._internal.operations.freeze import freeze
File "/usr/lib/python3.8/site-packages/pip/_internal/operations/freeze.py", line 17, in <module>
from pip._internal.req.constructors import (
File "/usr/lib/python3.8/site-packages/pip/_internal/req/__init__.py", line 11, in <module>
from .req_file import parse_requirements
File "/usr/lib/python3.8/site-packages/pip/_internal/req/req_file.py", line 25, in <module>
from pip._internal.req.constructors import (
File "/usr/lib/python3.8/site-packages/pip/_internal/req/constructors.py", line 28, in <module>
from pip._internal.req.req_install import InstallRequirement
File "/usr/lib/python3.8/site-packages/pip/_internal/req/req_install.py", line 30, in <module>
from pip._internal.operations.install.wheel import install_wheel
File "/usr/lib/python3.8/site-packages/pip/_internal/operations/install/wheel.py", line 33, in <module>
from pip._internal.utils.wheel import parse_wheel
File "/usr/lib/python3.8/site-packages/pip/_internal/utils/wheel.py", line 12, in <module>
from pip._vendor.six import PY2, ensure_str
ImportError: cannot import name 'ensure_str' from 'six' (/home/carl/.local/lib/python3.8/site-packages/six.py)
EDIT:
I was suggested to look at https://stackoverflow.com/a/57262415/13516940. And It says that 'ensure_str' is included in six 1.12 and forward, however I only have version 1.11. This explains why it cant be found. However I cannot fix this by for example running pip install --upgrade six nor pip uninstall six or pip check six. Because any of those commands give the same "cannot import name" error. Help to solve this would be greatly appreciated.
I had this problem within my virtual environment when installing from the requirements.txt file that came with the code. My system Python (3.8.5) ran just fine and on the system I had six==1.14.0, but the requirements.txt file had six==1.11.0. Thus, whenever I ran pip install -r requirements.txt within my venv things would break because it would install the older version of six.
My solution was to delete the first venv I created, change the line in requirements.txt to six==1.14.0 (the working version), rebuild my venv, and then install using the newly modified requirements.txt file. In hindsight this seems like common sense, but in the moment it didn't occur to me. In short: don't overwrite the working version of six with the older, non-compatible version.
Open the file /home/carl/.local/lib/python3.8/site-packages/six.py
Replace the content of file with the latest versión in https://github.com/benjaminp/six/blob/master/six.py
It works for me.
Taken from: https://www.reddit.com/r/learnpython/comments/igsaza/importerror_cannot_import_name_ensure_str_from/g2vqftq/?utm_source=reddit&utm_medium=web2x&context=3
my problem was PyCharm couldn't install any packages, i used #HaroldMideros's answer except the location was $pycharm_install_dir/plugins/python/helpers/six.py
I am trying to install tensorflow using the following command
sudo -H pip3 install --upgrade tensorflow
But I am facing the following error-
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pip/_vendor/__init__.py", line 33, in vendored
__import__(vendored_name, globals(), locals(), level=0)
ImportError: No module named 'pip._vendor.pkg_resources'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/bin/pip3", line 9, in <module>
from pip import main
File "/usr/lib/python3/dist-packages/pip/__init__.py", line 13, in <module>
from pip.exceptions import InstallationError, CommandError, PipError
File "/usr/lib/python3/dist-packages/pip/exceptions.py", line 6, in <module>
from pip._vendor.six import iteritems
File "/usr/lib/python3/dist-packages/pip/_vendor/__init__.py", line 75, in <module>
vendored("pkg_resources")
File "/usr/lib/python3/dist-packages/pip/_vendor/__init__.py", line 36, in vendored
__import__(modulename, globals(), locals(), level=0)
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
File "<frozen importlib._bootstrap>", line 634, in _load_backward_compatible
File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2927, in <module>
File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2913, in _call_aside
File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2952, in _initialize_master_working_set
File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 956, in subscribe
File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2952, in <lambda>
File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2515, in activate
File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2097, in declare_namespace
File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2047, in _handle_ns
File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2066, in _rebuild_mod_path
AttributeError: '_NamespacePath' object has no attribute 'sort'.
I have both the version of python 2.7 & python 3.5 installed. Please suggest a solution to get rid of this error.
I am trying to run MNIST prediction using tensorflow.
Files:
https://github.com/niektemme/tensorflow-mnist-predict/
CMD Line Code:
python predict_1.py ‘number1.png’
I can execute the program in PyCharm without an error, but when I try executing the script through the command line, I get an error.
Traceback (most recent call last):
File "predict_1.py", line 29, in <module>
import tensorflow as tf
ModuleNotFoundError: No module named 'tensorflow'
I checked pip3 list to confirm installed:
tensorflow (1.0.1)
Update1:
I ran this test in both environments:
import os
print(os.file)
PyCharm:
C:\Users\\AppData\Local\Programs\Python\Python35\python.exe
C:/Users//AppData/Local/Programs/Python/Python35/Scripts/tensorflow-mnist-predict-master/tensorflow-mnist-predict-master/test.py
C:\Users\\AppData\Local\Programs\Python\Python35\lib\os.py
CMD Line:
C:\ProgramData\Anaconda3\lib\os.py
Update2:
I removed Anaconda3 from the environment variables, and
CMD Line now reads:
C:\Users\\AppData\Local\Programs\Python\Python35\lib\os.py
This is the error I get trying to run tensorflow through the CMD line:
Traceback (most recent call last):
File "C:\Users\\AppData\Local\Programs\Python\Python35\Lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "C:\Users\\AppData\Local\Programs\Python\Python35\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 666, in _load_unlocked
File "<frozen importlib._bootstrap>", line 577, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 906, in create_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
ImportError: DLL load failed: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\\AppData\Local\Programs\Python\Python35\Lib\site-packages\tensorflow\python\__init__.py", line 54, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\\AppData\Local\Programs\Python\Python35\Lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 21, in <module>
_pywrap_tensorflow = swig_import_helper()
File "C:\Users\\AppData\Local\Programs\Python\Python35\Lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 20, in swig_import_helper
return importlib.import_module('_pywrap_tensorflow')
File "C:\Users\\AppData\Local\Programs\Python\Python35\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: No module named '_pywrap_tensorflow'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "predict_1.py", line 29, in <module>
import tensorflow as tf
File "C:\Users\\AppData\Local\Programs\Python\Python35\Lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import *
File "C:\Users\\AppData\Local\Programs\Python\Python35\Lib\site-packages\tensorflow\python\__init__.py", line 60, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\\AppData\Local\Programs\Python\Python35\Lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "C:\Users\\AppData\Local\Programs\Python\Python35\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 666, in _load_unlocked
File "<frozen importlib._bootstrap>", line 577, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 906, in create_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
ImportError: DLL load failed: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\\AppData\Local\Programs\Python\Python35\Lib\site-packages\tensorflow\python\__init__.py", line 54, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\\AppData\Local\Programs\Python\Python35\Lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 21, in <module>
_pywrap_tensorflow = swig_import_helper()
File "C:\Users\\AppData\Local\Programs\Python\Python35\Lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 20, in swig_import_helper
return importlib.import_module('_pywrap_tensorflow')
File "C:\Users\\AppData\Local\Programs\Python\Python35\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: No module named '_pywrap_tensorflow'
Error importing tensorflow. Unless you are using bazel,
you should not try to import tensorflow from its source directory;
please exit the tensorflow source tree, and relaunch your python interpreter from there.
Judging from your edits, you have two separate python installations, one in Users\AppData and one in ProgramData\Anaconda3. Your PyCharm uses the first one, but when you just run python command from CLI you get the second one. There are two ways to resolve this, you can adjust your PATH variable to point to the first installation, so python from CLI is the same as your PyCharm or you can install TensorFlow on the second install (this might lead to further confusion if there are other libraries your code depends on). Here is a link with directions on editing your PATH variable (https://www.howtogeek.com/118594/how-to-edit-your-system-path-for-easy-command-line-access/). You want to make sure that C:\Users\\AppData\Local\Programs\Python\Python35 is in there and C:\ProgramData\Anaconda3 is not.