pip apt-pkg problems in ubuntu 20.04 - python-3.x

I am new at linux(ubuntu 20.04), facing problem to installation of pip apt-pkg as following,
curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10
Traceback (most recent call last):
File "/usr/lib/command-not-found", line 28, in
from CommandNotFound import CommandNotFound
File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 19, in
from CommandNotFound.db.db import SqliteDatabase
File "/usr/lib/python3/dist-packages/CommandNotFound/db/db.py", line 5, in
import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'
pradeep#pradeep-Vostro-15-3568:~$ pip install pip
Traceback (most recent call last):
File "/usr/bin/pip", line 11, in
load_entry_point('pip==20.0.2', 'console_scripts', 'pip')()
File "/usr/lib/python3/dist-packages/pip/_internal/cli/main.py", line 73, in main
command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
File "/usr/lib/python3/dist-packages/pip/_internal/commands/init.py", line 96, in create_command
module = importlib.import_module(module_path)
File "/usr/lib/python3.10/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1050, in _gcd_import
File "", line 1027, in _find_and_load
File "", line 1006, in _find_and_load_unlocked
File "", line 688, in _load_unlocked
File "", line 883, in exec_module
File "", line 241, in _call_with_frames_removed
File "/usr/lib/python3/dist-packages/pip/_internal/commands/install.py", line 24, in
from pip._internal.cli.req_command import RequirementCommand
File "/usr/lib/python3/dist-packages/pip/_internal/cli/req_command.py", line 15, in
from pip._internal.index.package_finder import PackageFinder
File "/usr/lib/python3/dist-packages/pip/_internal/index/package_finder.py", line 21, in
from pip._internal.index.collector import parse_links
File "/usr/lib/python3/dist-packages/pip/_internal/index/collector.py", line 12, in
from pip._vendor import html5lib, requests
ImportError: cannot import name 'html5lib' from 'pip._vendor' (/usr/lib/python3/dist-packages/pip/_vendor/init.py)

Related

Tests failling after django and python upgrade

I've upgraded Django from 4.0.5 to 4.1.6 and python from 3.9 to 3.11
I've also upgraded dependencies:
pip==23.0
pytest==7.2.1
pytest-django==4.5.2
coverage==7.1.0
pytest-cov==4.0.0
pylint==2.16.2
mock==5.0.1
These are my logs:
django-admin test
Traceback (most recent call last):
File "/usr/local/bin/django-admin", line 8, in <module>
sys.exit(execute_from_command_line())
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.11/site-packages/django/core/management/__init__.py", line 440, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.11/site-packages/django/core/management/commands/test.py", line 24, in run_from_argv
super().run_from_argv(argv)
File "/usr/local/lib/python3.11/site-packages/django/core/management/base.py", line 394, in run_from_argv
parser = self.create_parser(argv[0], argv[1])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django/core/management/base.py", line 357, in create_parser
self.add_arguments(parser)
File "/usr/local/lib/python3.11/site-packages/django/core/management/commands/test.py", line 54, in add_arguments
test_runner_class = get_runner(settings, self.test_runner)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django/test/utils.py", line 394, in get_runner
test_module = __import__(test_module_name, {}, {}, test_path[-1])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django_coverage/coverage_runner.py", line 31, in <module>
from django.db.models import get_app, get_apps
ImportError: cannot import name 'get_app' from 'django.db.models' (/usr/local/lib/python3.11/site-packages/django/db/models/__init__.py)
It works with
from django.apps import apps
Import Error :cannot import name get_model
But I have other issues with this library which is very old and I removed it from my project.
Ex:
django-admin test
Traceback (most recent call last):
File "/usr/local/bin/django-admin", line 8, in <module>
sys.exit(execute_from_command_line())
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.11/site-packages/django/core/management/__init__.py", line 440, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.11/site-packages/django/core/management/commands/test.py", line 24, in run_from_argv
super().run_from_argv(argv)
File "/usr/local/lib/python3.11/site-packages/django/core/management/base.py", line 394, in run_from_argv
parser = self.create_parser(argv[0], argv[1])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django/core/management/base.py", line 357, in create_parser
self.add_arguments(parser)
File "/usr/local/lib/python3.11/site-packages/django/core/management/commands/test.py", line 54, in add_arguments
test_runner_class = get_runner(settings, self.test_runner)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django/test/utils.py", line 394, in get_runner
test_module = __import__(test_module_name, {}, {}, test_path[-1])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/django_coverage/coverage_runner.py", line 37, in <module>
from django_coverage.utils.coverage_report import html_report
File "/usr/local/lib/python3.11/site-packages/django_coverage/utils/coverage_report/__init__.py", line 17, in <module>
from html_report import *
ModuleNotFoundError: No module named 'html_report'

Buildozer fail to compile .apk because 'xrange' is not defined

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!

OSError: libgdal.so.27: cannot open shared object file: No such file or directory

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

ImportError while installing tensorflow in Ubuntu 16.04

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.

TensorFlow importerror on windows cmd

I have installed python 3.5.2, and installed TensorFlow throght the command
pip3 install tensorflow --upgrade
After the installation finished, I try to import the TensorFlow, but failed. The error report is as follow. How to fix this problem?
import tensorflow Traceback (most recent call last): File "C:\Python\Python352\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py",
line 18, in swig_import_helper
return importlib.import_module(mname) File "C:\Python\Python352\lib\importlib__init__.py", line 126, in
import_module
return _bootstrap._gcd_import(name[level:], package, level) File "", line 986, in _gcd_import File
"", line 969, in _find_and_load File
"", line 958, in _find_and_load_unlocked
File "", line 666, in _load_unlocked
File "", line 577, in module_from_spec
File "", line 906, in
create_module File "", line 222, in
_call_with_frames_removed ImportError: DLL load failed: 找不到指定的模块。(Could not find the moudle)
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"C:\Python\Python352\lib\site-packages\tensorflow\python\pywrap_tensorflow.py",
line 41, in
from tensorflow.python.pywrap_tensorflow_internal import * File "C:\Python\Python352\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py",
line 21, in
_pywrap_tensorflow_internal = swig_import_helper() File "C:\Python\Python352\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py",
line 20, in swig_import_helper
return importlib.import_module('_pywrap_tensorflow_internal') File "C:\Python\Python352\lib\importlib__init__.py", line 126, in
import_module
return _bootstrap._gcd_import(name[level:], package, level) ImportError: No module named '_pywrap_tensorflow_internal'
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "", line 1, in
File
"C:\Python\Python352\lib\site-packages\tensorflow__init__.py", line
24, in
from tensorflow.python import * File "C:\Python\Python352\lib\site-packages\tensorflow\python__init__.py",
line 51, in
from tensorflow.python import pywrap_tensorflow File "C:\Python\Python352\lib\site-packages\tensorflow\python\pywrap_tensorflow.py",
line 52, in
raise ImportError(msg) ImportError: Traceback (most recent call last): File
"C:\Python\Python352\lib\site-packages\tensorflow\python\pywrap_tensorflo
w_internal.py", line 18, in swig_import_helper
return importlib.import_module(mname) File "C:\Python\Python352\lib\importlib__init__.py", line 126, in
import_module
return _bootstrap._gcd_import(name[level:], package, level) File "", line 986, in _gcd_import File
"", line 969, in _find_and_load File
"", line 958, in _find_and_load_unlocked
File "", line 666, in _load_unlocked
File "", line 577, in module_from_spec
File "", line 906, in
create_module File "", line 222, in
_call_with_frames_removed ImportError: DLL load failed: 找不到指定的模块。(could not find the moudle)
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"C:\Python\Python352\lib\site-packages\tensorflow\python\pywrap_tensorflo
w.py", line 41, in
from tensorflow.python.pywrap_tensorflow_internal import * File "C:\Python\Python352\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py",
line 21, in
_pywrap_tensorflow_internal = swig_import_helper() File "C:\Python\Python352\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py",
line 20, in swig_import_helper
return importlib.import_module('_pywrap_tensorflow_internal') File "C:\Python\Python352\lib\importlib__init__.py", line 126, in
import_module
return _bootstrap._gcd_import(name[level:], package, level) ImportError: No module named '_pywrap_tensorflow_internal'
Failed to load the native TensorFlow runtime.

Resources