Install GDAL on Python 2.7 on a Amazon Linux virtual server - linux

I have a t2.micro Amazon Linux instance running.
Python 2.7.12 is pre-installed already. I would like to install GDAL with the Python.
I have got gcc c++ and numpy installed.
None of the following commands worked for me:
sudo yum install gdal-devel
sudo yum install gdal
sudo yum install python-gdal
They all resulted in a following message saying.
No package {PACKAGE_NAME} available.
Error: Nothing to do
I cannot run apt-get on a Amazon Linux instance.
Also none of the relevant SO posts worked for me either.
I also ran
sudo easy_install GDAL
and this gave a MemoryError as below:
Searching for GDAL
Reading https://pypi.python.org/simple/GDAL/
Best match: GDAL 2.2.1
Downloading https://pypi.python.org/packages/f2/c3/1cadfcae9a4330c3a68c41e3bc96a5d228883eec6ea3e2fc6321165b863c/GDAL-2.2.1.tar.gz#md5=4d78446b1053825a2d15b70730288b0f
Processing GDAL-2.2.1.tar.gz
Writing /tmp/easy_install-1VNr7G/GDAL-2.2.1/setup.cfg
Running GDAL-2.2.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-1VNr7G/GDAL-2.2.1/egg-dist-tmp-q1jQCi
Traceback (most recent call last):
File "/usr/bin/easy_install", line 9, in <module>
load_entry_point('setuptools==12.2', 'console_scripts', 'easy_install-2.7')()
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 2297, in main
distclass=DistributionWithoutHelpCommands, **kw
File "/usr/lib64/python2.7/distutils/core.py", line 151, in setup
dist.run_commands()
File "/usr/lib64/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/usr/lib64/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 393, in run
self.easy_install(spec, not self.no_deps)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 642, in easy_install
return self.install_item(spec, dist.location, tmpdir, deps)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 672, in install_item
dists = self.install_eggs(spec, download, tmpdir)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 857, in install_eggs
return self.build_and_install(setup_script, setup_base)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 1085, in build_and_install
self.run_setup(setup_script, setup_base, args)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 1071, in run_setup
run_setup(setup_script, args)
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 240, in run_setup
raise
File "/usr/lib64/python2.7/contextlib.py", line 35, in __exit__
self.gen.throw(type, value, traceback)
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 193, in setup_context
yield
File "/usr/lib64/python2.7/contextlib.py", line 35, in __exit__
self.gen.throw(type, value, traceback)
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 152, in save_modules
yield saved
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 126, in __exit__
self._saved = UnpickleableException.dump(type, exc)
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump
return cls.dump(cls, cls(repr(exc)))
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump
return cls.dump(cls, cls(repr(exc)))
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump
return cls.dump(cls, cls(repr(exc)))
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump
return cls.dump(cls, cls(repr(exc)))
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump
return cls.dump(cls, cls(repr(exc)))
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump
return cls.dump(cls, cls(repr(exc)))
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump
return cls.dump(cls, cls(repr(exc)))
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump
return cls.dump(cls, cls(repr(exc)))
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump
return cls.dump(cls, cls(repr(exc)))
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump
return cls.dump(cls, cls(repr(exc)))
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump
return cls.dump(cls, cls(repr(exc)))
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump
return cls.dump(cls, cls(repr(exc)))
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump
return cls.dump(cls, cls(repr(exc)))
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump
return cls.dump(cls, cls(repr(exc)))
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump
return cls.dump(cls, cls(repr(exc)))
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump
return cls.dump(cls, cls(repr(exc)))
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump
return cls.dump(cls, cls(repr(exc)))
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump
return cls.dump(cls, cls(repr(exc)))
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump
return cls.dump(cls, cls(repr(exc)))
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump
return cls.dump(cls, cls(repr(exc)))
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump
return cls.dump(cls, cls(repr(exc)))
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump
return cls.dump(cls, cls(repr(exc)))
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump
return cls.dump(cls, cls(repr(exc)))
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump
return cls.dump(cls, cls(repr(exc)))
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump
return cls.dump(cls, cls(repr(exc)))
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump
return cls.dump(cls, cls(repr(exc)))
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump
return cls.dump(cls, cls(repr(exc)))
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump
return cls.dump(cls, cls(repr(exc)))
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump
return cls.dump(cls, cls(repr(exc)))
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump
return cls.dump(cls, cls(repr(exc)))
MemoryError

Its in the EPEL respository. Try this:
sudo yum-config-manager --enable epel
sudo yum install gdal-python
sudo yum -y update
sudo yum -y install make automake gcc gcc-c++ libcurl-devel proj-devel geos-devel
cd /tmp
curl -L http://download.osgeo.org/gdal/2.0.0/gdal-2.0.0.tar.gz | tar zxf -
cd gdal-2.0.0/
./configure --prefix=/usr/local --with-python
make -j4
sudo make install
sudo easy_install GDAL
export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"
sudo ldconfig
I was able to get this to work on a fresh t2.micro running amazon linux.
The final export needs to be made permanent in bash script or the relevant place depending on your needs.
Following this I was able to from osgeo import gdal
You can make clean in the /tmp/gdal-2.0.0 folder to free up some space when done.
Warn - Build took a long time on a t2.micro

I followed this link on my EC2 instance (m4.large) which has Amazon Linux and python 2.7. It worked perfectly for me (I changed Gdal 2.0.0 to 2.2.0). Just make sure you have all the dependencies (ie numpy and libgdal). Let me know if you have any questions!

Nix package manager worked for me:
curl https://nixos.org/nix/install | sh
. /home/ec2-user/.nix-profile/etc/profile.d/nix.sh
nix-env -i gdal

Related

dbbackup with docker/celery/celery-beat not working: [Errno 2] No such file or directory: 'pg_dump'

I am setting up a backup to use dbbackup. However, I am receiving an error when backing up my data. There is a similar question where the person was able to resolve it, however, the answer doesn't show how. here
My dbbackup version is django-dbbackup==4.0.2
Please find below my dockerfile:
database:
build:
context: .
dockerfile: pg-Dockerfile
expose:
- "5432"
restart: always
volumes:
- .:/myworkdir
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: faranga_db
redis:
image: redis
restart: on-failure
volumes:
- .:/myworkdir
expose:
- "6379"
celery:
build: .
restart: on-failure
command: bash -c "sleep 10; celery -A project worker -l info"
volumes:
- .:/myworkdir
env_file:
- .env
depends_on:
- database
- redis
beat:
build: .
restart: on-failure
command: bash -c "sleep 10; celery -A project beat -l info --pidfile=/tmp/celeryd.pid"
volumes:
- .:/myworkdir
env_file:
- .env
depends_on:
- database
- redis
my celery task:
#app.task
def database_backup():
management.call_command('dbbackup')
# media backup works just fine
#app.task
def media_backup():
management.call_command('mediabackup')
DB backup settings
# django db backup https://django-dbbackup.readthedocs.io/en/master/installation.html
DBBACKUP_STORAGE = 'django.core.files.storage.FileSystemStorage'
DBBACKUP_STORAGE_OPTIONS = {'location': '~/myworkdir/backups/db/'}
def backup_filename(databasename, servername, datetime, extension, content_type):
pass
DBBACKUP_FILENAME_TEMPLATE = backup_filename
DBBACKUP_CONNECTOR = "dbbackup.db.postgresql.PgDumpBinaryConnector"
Error stack trace:
[2023-02-09 14:44:00,052: ERROR/ForkPoolWorker-6] CommandConnectorError: Error running: pg_dump --dbname=postgresql://postgres:password#database:5432/faranga_db --format=custom
faranga-celery-1 | [Errno 2] No such file or directory: 'pg_dump'
faranga-celery-1 | File "/usr/local/lib/python3.10/dist-packages/dbbackup/utils.py", line 120, in wrapper
faranga-celery-1 | func(*args, **kwargs)
faranga-celery-1 | File "/usr/local/lib/python3.10/dist-packages/dbbackup/management/commands/dbbackup.py", line 93, in handle
faranga-celery-1 | self._save_new_backup(database)
faranga-celery-1 | File "/usr/local/lib/python3.10/dist-packages/dbbackup/management/commands/dbbackup.py", line 106, in _save_new_backup
faranga-celery-1 | outputfile = self.connector.create_dump()
faranga-celery-1 | File "/usr/local/lib/python3.10/dist-packages/dbbackup/db/base.py", line 92, in create_dump
faranga-celery-1 | return self._create_dump()
faranga-celery-1 | File "/usr/local/lib/python3.10/dist-packages/dbbackup/db/postgresql.py", line 112, in _create_dump
faranga-celery-1 | stdout, stderr = self.run_command(cmd, env=self.dump_env)
faranga-celery-1 | File "/usr/local/lib/python3.10/dist-packages/dbbackup/db/base.py", line 180, in run_command
faranga-celery-1 | raise exceptions.CommandConnectorError(
faranga-celery-1 |
faranga-celery-1 | [2023-02-09 14:44:00,080: ERROR/ForkPoolWorker-6] Task administration.tasks.database_backup[601e33a6-0eef-42c0-a355-cb7d33d7ebaa] raised unexpected: CommandConnectorError("Error running: pg_dump --dbname=postgresql://postgres:password#database:5432/faranga_db --format=custom \n[Errno 2] No such file or directory: 'pg_dump'")
faranga-celery-1 | Traceback (most recent call last):
faranga-celery-1 | File "/usr/local/lib/python3.10/dist-packages/dbbackup/db/base.py", line 165, in run_command
faranga-celery-1 | process = Popen(
faranga-celery-1 | File "/usr/local/lib/python3.10/dist-packages/sentry_sdk/integrations/stdlib.py", line 201, in sentry_patched_popen_init
faranga-celery-1 | rv = old_popen_init(self, *a, **kw)
faranga-celery-1 | File "/usr/lib/python3.10/subprocess.py", line 969, in __init__
faranga-celery-1 | self._execute_child(args, executable, preexec_fn, close_fds,
faranga-celery-1 | File "/usr/lib/python3.10/subprocess.py", line 1845, in _execute_child
faranga-celery-1 | raise child_exception_type(errno_num, err_msg, err_filename)
faranga-celery-1 | FileNotFoundError: [Errno 2] No such file or directory: 'pg_dump'
faranga-celery-1 |
faranga-celery-1 | During handling of the above exception, another exception occurred:
faranga-celery-1 |
faranga-celery-1 | Traceback (most recent call last):
faranga-celery-1 | File "/usr/local/lib/python3.10/dist-packages/celery/app/trace.py", line 451, in trace_task
faranga-celery-1 | R = retval = fun(*args, **kwargs)
faranga-celery-1 | File "/usr/local/lib/python3.10/dist-packages/sentry_sdk/integrations/celery.py", line 207, in _inner
faranga-celery-1 | reraise(*exc_info)
faranga-celery-1 | File "/usr/local/lib/python3.10/dist-packages/sentry_sdk/_compat.py", line 56, in reraise
faranga-celery-1 | raise value
faranga-celery-1 | File "/usr/local/lib/python3.10/dist-packages/sentry_sdk/integrations/celery.py", line 202, in _inner
faranga-celery-1 | return f(*args, **kwargs)
faranga-celery-1 | File "/usr/local/lib/python3.10/dist-packages/celery/app/trace.py", line 734, in __protected_call__
faranga-celery-1 | return self.run(*args, **kwargs)
faranga-celery-1 | File "/myworkdir/administration/tasks.py", line 8, in database_backup
faranga-celery-1 | management.call_command('dbbackup')
faranga-celery-1 | File "/usr/local/lib/python3.10/dist-packages/django/core/management/__init__.py", line 181, in call_command
faranga-celery-1 | return command.execute(*args, **defaults)
faranga-celery-1 | File "/usr/local/lib/python3.10/dist-packages/django/core/management/base.py", line 398, in execute
faranga-celery-1 | output = self.handle(*args, **options)
faranga-celery-1 | File "/usr/local/lib/python3.10/dist-packages/dbbackup/utils.py", line 120, in wrapper
faranga-celery-1 | func(*args, **kwargs)
faranga-celery-1 | File "/usr/local/lib/python3.10/dist-packages/dbbackup/management/commands/dbbackup.py", line 93, in handle
faranga-celery-1 | self._save_new_backup(database)
faranga-celery-1 | File "/usr/local/lib/python3.10/dist-packages/dbbackup/management/commands/dbbackup.py", line 106, in _save_new_backup
faranga-celery-1 | outputfile = self.connector.create_dump()
faranga-celery-1 | File "/usr/local/lib/python3.10/dist-packages/dbbackup/db/base.py", line 92, in create_dump
faranga-celery-1 | return self._create_dump()
faranga-celery-1 | File "/usr/local/lib/python3.10/dist-packages/dbbackup/db/postgresql.py", line 112, in _create_dump
faranga-celery-1 | stdout, stderr = self.run_command(cmd, env=self.dump_env)
faranga-celery-1 | File "/usr/local/lib/python3.10/dist-packages/dbbackup/db/base.py", line 180, in run_command
faranga-celery-1 | raise exceptions.CommandConnectorError(
faranga-celery-1 | dbbackup.db.exceptions.CommandConnectorError: Error running: pg_dump --dbname=postgresql://postgres:password#database:5432/faranga_db --format=custom
faranga-celery-1 | [Errno 2] No such file or directory: 'pg_dump'
If you´re running this command inside your project container, you don´t have access to the postgres binaries to dump and restore your database. Try access your postgres container and call this command in shell.
You could get you database container id from docker ps and access your container shell with docker exec -it [your_container_id] bash . Then try to call pg_dump from inside of it. This should probably work

upload egg file raise an DistributionNotFound exception for requirements package

Description
When I tried to deploy an egg file to the scrapyd server within a docker container, it always returned a DistributionNotFound error for each external package.
I tried both with curl and scrapyd-deploy
Steps to Reproduce
python setup.py bdist_uberegg -r requirements.txt
curl http://localhost:13334/addversion.json -F project=pr_reviews -F version=1.0.0 -F egg=.\dist\project-1.0-py3.10.egg
or
scrapyd-deploy --include-dependencies
Actual behavior: [What actually happens]
$ curl http://localhost:13334/addversion.json -F project=pr_reviews -F version=re1 -F egg=#".\dist\project-1.0-py3.10.egg"
{"node_name": "e9e273febed8", "status": "error", "message": "/usr/local/lib/python3.9/dist-packages/scrapy/utils/project.py:81: ScrapyDeprecationWarning: Use of environment variables prefixed with SCRAPY_ to override settings is deprecated. The following environment variables are currently defined: EGG_VERSION\n warnings.warn(\nTraceback (most recent call last):\n File \"/usr/lib/python3.9/runpy.py\", line 197, in _run_module_as_main\n return _run_code(code, main_globals, None,\n File \"/usr/lib/python3.9/runpy.py\", line 87, in _run_code\n exec(code, run_globals)\n File \"/usr/local/lib/python3.9/dist-packages/scrapyd/runner.py\", line 46, in <module>\n main()\n File \"/usr/local/lib/python3.9/dist-packages/scrapyd/runner.py\", line 43, in main\n execute()\n File \"/usr/local/lib/python3.9/dist-packages/scrapy/cmdline.py\", line 144, in execute\n cmd.crawler_process = CrawlerProcess(settings)\n File \"/usr/local/lib/python3.9/dist-packages/scrapy/crawler.py\", line 290, in __init__\n super().__init__(settings)\n File \"/usr/local/lib/python3.9/dist-packages/scrapy/crawler.py\", line 167, in __init__\n self.spider_loader = self._get_spider_loader(settings)\n
File \"/usr/local/lib/python3.9/dist-packages/scrapy/crawler.py\", line 161, in _get_spider_loader\n return loader_cls.from_settings(settings.frozencopy())\n File \"/usr/local/lib/python3.9/dist-packages/scrapy/spiderloader.py\", line 67, in from_settings\n return cls(settings)\n File \"/usr/local/lib/python3.9/dist-packages/scrapy/spiderloader.py\", line 24, in __init__\n self._load_all_spiders()\n File \"/usr/local/lib/python3.9/dist-packages/scrapy/spiderloader.py\", line 51, in _load_all_spiders\n for module in walk_modules(name):\n File \"/usr/local/lib/python3.9/dist-packages/scrapy/utils/misc.py\", line 88, in walk_modules\n submod = import_module(fullpath)\n File \"/usr/lib/python3.9/importlib/__init__.py\", line 127, in import_module\n return _bootstrap._gcd_import(name[level:], package, level)\n File \"<frozen importlib._bootstrap>\", line 1030, in _gcd_import\n File \"<frozen importlib._bootstrap>\", line 1007, in _find_and_load\n File \"<frozen importlib._bootstrap>\", line 986, in _find_and_load_unlocked\n File \"<frozen importlib._bootstrap>\", line 664, in _load_unlocked\n File \"<frozen importlib._bootstrap>\", line 627, in _load_backward_compatible\n File \"<frozen zipimport>\", line 259, in load_module\n File \"/tmp/pr_reviews-re1-vukl7x51.egg/pr_reviews/spiders/ReviewCrawler.py\", line 2, in <module>\n File \"<frozen importlib._bootstrap>\", line 1007, in _find_and_load\n File \"<frozen importlib._bootstrap>\", line 986, in _find_and_load_unlocked\n File \"<frozen importlib._bootstrap>\", line 664, in _load_unlocked\n File \"<frozen importlib._bootstrap>\", line 627, in _load_backward_compatible\n File \"<frozen zipimport>\", line 259, in load_module\n File \"/tmp/pr_reviews-re1-vukl7x51.egg/pr_reviews/items.py\", line 4, in <module>\n File \"<frozen importlib._bootstrap>\", line 1007, in _find_and_load\n File \"<frozen importlib._bootstrap>\", line 986, in _find_and_load_unlocked\n File \"<frozen importlib._bootstrap>\", line 664, in _load_unlocked\n File \"<frozen importlib._bootstrap>\", line 627, in _load_backward_compatible\n File \"<frozen zipimport>\", line 259, in load_module\n File \"/tmp/pr_reviews-re1-vukl7x51.egg/pycountry/__init__.py\", line 13, in <module>\n File \"/usr/local/lib/python3.9/dist-packages/pkg_resources/__init__.py\", line 478, in get_distribution\n dist = get_provider(dist)\n File \"/usr/local/lib/python3.9/dist-packages/pkg_resources/__init__.py\", line 354, in get_provider\n return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]\n File \"/usr/local/lib/python3.9/dist-packages/pkg_resources/__init__.py\", line 909, in require\n needed = self.resolve(parse_requirements(requirements))\n File \"/usr/local/lib/python3.9/dist-packages/pkg_resources/__init__.py\", line 795, in resolve\n raise DistributionNotFound(req, requirers)\npkg_resources.DistributionNotFound: The 'pycountry' distribution was not found and is required by the application\n"}
setup.py
from setuptools import setup, find_packages
setup(
name='project',
version='1.0',
packages=find_packages(),
install_requires=[
"itemadapter",
"langdetect",
"pycountry",
"scrapy",
"setuptools",
"scrapy_zyte_smartproxy",
"scrapy_user_agents"
],
entry_points={'scrapy': ['settings = pr_reviews.settings']},
)
requirements.txt
itemadapter==0.6.0
langdetect==1.0.9
pycountry==22.3.5
scrapy==2.6.1
setuptools==63.1.0
scrapy_zyte_smartproxy==2.1.0
scrapy_user_agents==0.1.1
Scrapd server
FROM ubuntu:20.04
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update -qq \
&& apt-get install -y tini git python3.9 python3.9-dev python3.9-distutils curl python3.9-venv build-essential libxml2-dev libxslt1-dev zlib1g-dev libffi-dev libssl-dev nginx apache2-utils \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
RUN python3.9 get-pip.py
ADD requirements.txt /
RUN python3.9 -m pip install -r /requirements.txt
RUN python3.9 -m pip install -e git+https://github.com/necrophcodr/chaperone.git#egg=chaperone
RUN mkdir /etc/chaperone.d
COPY ./scrapyd.conf /etc/scrapyd/
VOLUME /etc/scrapyd/ /var/lib/scrapyd/
EXPOSE 6800
ENTRYPOINT ["tini", "--"]
CMD ["scrapyd", "--pidfile="]

lief package error while installing MOBSF

Building wheel for lief (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-vgv9vwph/lief/setup.py'"'"'; file='"'"'/tmp/pip-install-vgv9vwph/lief/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-7w2iswl4
cwd: /tmp/pip-install-vgv9vwph/lief/
Complete output (46 lines):
0.10.1
running bdist_wheel
running build
running build_ext
Traceback (most recent call last):
File "/tmp/pip-install-vgv9vwph/lief/setup.py", line 72, in run
subprocess.check_output(['cmake', '--version'])
File "/usr/lib/python3.8/subprocess.py", line 411, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
File "/usr/lib/python3.8/subprocess.py", line 489, in run
with Popen(*popenargs, **kwargs) as process:
File "/usr/lib/python3.8/subprocess.py", line 854, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib/python3.8/subprocess.py", line 1702, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'cmake'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "", line 1, in
File "/tmp/pip-install-vgv9vwph/lief/setup.py", line 363, in
setup(
File "/home/kali/.local/lib/python3.8/site-packages/setuptools/init.py", line 153, in setup
return distutils.core.setup(**attrs)
File "/usr/lib/python3.8/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/lib/python3.8/distutils/dist.py", line 966, in run_commands
self.run_command(cmd)
File "/usr/lib/python3.8/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/usr/lib/python3/dist-packages/wheel/bdist_wheel.py", line 223, in run
self.run_command('build')
File "/usr/lib/python3.8/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib/python3.8/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/usr/lib/python3.8/distutils/command/build.py", line 135, in run
self.run_command(cmd_name)
File "/usr/lib/python3.8/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib/python3.8/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/tmp/pip-install-vgv9vwph/lief/setup.py", line 74, in run
raise RuntimeError("CMake must be installed to build the following extensions: " +
RuntimeError: CMake must be installed to build the following extensions: lief
ERROR: Failed building wheel for lief
Running setup.py clean for lief
Failed to build lief
Installing collected packages: lief
Running setup.py install for lief ... error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-vgv9vwph/lief/setup.py'"'"'; file='"'"'/tmp/pip-install-vgv9vwph/lief/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /tmp/pip-record-hb45g1s1/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/kali/.local/include/python3.8/lief
cwd: /tmp/pip-install-vgv9vwph/lief/
Complete output (48 lines):
0.10.1
running install
running build
running build_ext
Traceback (most recent call last):
File "/tmp/pip-install-vgv9vwph/lief/setup.py", line 72, in run
subprocess.check_output(['cmake', '--version'])
File "/usr/lib/python3.8/subprocess.py", line 411, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
File "/usr/lib/python3.8/subprocess.py", line 489, in run
with Popen(*popenargs, **kwargs) as process:
File "/usr/lib/python3.8/subprocess.py", line 854, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib/python3.8/subprocess.py", line 1702, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'cmake'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-vgv9vwph/lief/setup.py", line 363, in <module>
setup(
File "/home/kali/.local/lib/python3.8/site-packages/setuptools/__init__.py", line 153, in setup
return distutils.core.setup(**attrs)
File "/usr/lib/python3.8/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/lib/python3.8/distutils/dist.py", line 966, in run_commands
self.run_command(cmd)
File "/usr/lib/python3.8/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/home/kali/.local/lib/python3.8/site-packages/setuptools/command/install.py", line 61, in run
return orig.install.run(self)
File "/usr/lib/python3.8/distutils/command/install.py", line 589, in run
self.run_command('build')
File "/usr/lib/python3.8/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib/python3.8/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/usr/lib/python3.8/distutils/command/build.py", line 135, in run
self.run_command(cmd_name)
File "/usr/lib/python3.8/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib/python3.8/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/tmp/pip-install-vgv9vwph/lief/setup.py", line 74, in run
raise RuntimeError("CMake must be installed to build the following extensions: " +
RuntimeError: CMake must be installed to build the following extensions: lief
----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-vgv9vwph/lief/setup.py'"'"'; file='"'"'/tmp/pip-install-vgv9vwph/lief/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /tmp/pip-record-hb45g1s1/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/kali/.local/include/python3.8/lief Check the logs for full command output.
You need to install CMake and it has to be in a path accessible by python.
If you are using homebrew,
brew install cmake
Noticed you were using kali
apt install cmake

xclip and xsel - FileNotFoundError: [Errno 2]

I have kivy 1.10.1, python 3.8.2 and I code on Ubuntu20.04.
When I launch my little program, I receive this error:
[CRITICAL] [Cutbuffer ] Unable to find any valuable Cutbuffer provider.
xclip - FileNotFoundError: [Errno 2] Aucun fichier ou dossier de ce type: 'xclip'
File "/usr/lib/python3/dist-packages/kivy/core/__init__.py", line 55, in core_select_lib
mod = __import__(name='{2}.{0}.{1}'.format(
File "/usr/lib/python3/dist-packages/kivy/core/clipboard/clipboard_xclip.py", line 17, in <module>
p = subprocess.Popen(['xclip', '-version'], stdout=subprocess.PIPE)
File "/usr/lib/python3.8/subprocess.py", line 854, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib/python3.8/subprocess.py", line 1702, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
xsel - FileNotFoundError: [Errno 2] Aucun fichier ou dossier de ce type: 'xsel'
File "/usr/lib/python3/dist-packages/kivy/core/__init__.py", line 55, in core_select_lib
mod = __import__(name='{2}.{0}.{1}'.format(
File "/usr/lib/python3/dist-packages/kivy/core/clipboard/clipboard_xsel.py", line 16, in <module>
p = subprocess.Popen(['xsel'], stdout=subprocess.PIPE)
File "/usr/lib/python3.8/subprocess.py", line 854, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib/python3.8/subprocess.py", line 1702, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
How can I fix it, please?
The solution is just to install xclip with this command:
sudo apt-get install xclip

sudo -H -u git gitosis-init < ~/id_rsa.pub | error: no such file or directory

I got this shell script from a blog about how to equip git with gitosis.
But i got a "No such file or directory" error after running the script.
[git#209285 ~]$ sudo -H -u git gitosis-init < ~/id_rsa.pub
Traceback (most recent call last):
File "/usr/local/bin/gitosis-init", line 9, in <module>
load_entry_point('gitosis==0.2', 'console_scripts', 'gitosis-init')()
File "/usr/local/lib/python2.7/site-packages/gitosis-0.2-py2.7.egg/gitosis/app.py", line 24, in run
return app.main()
File "/usr/local/lib/python2.7/site-packages/gitosis-0.2-py2.7.egg/gitosis/app.py", line 38, in main
self.handle_args(parser, cfg, options, args)
File "/usr/local/lib/python2.7/site-packages/gitosis-0.2-py2.7.egg/gitosis/init.py", line 138, in handle_args
user=user,
File "/usr/local/lib/python2.7/site-packages/gitosis-0.2-py2.7.egg/gitosis/init.py", line 75, in init_admin_repository
template=resource_filename('gitosis.templates', 'admin')
File "/usr/local/lib/python2.7/site-packages/gitosis-0.2-py2.7.egg/gitosis/repository.py", line 63, in init
close_fds=True,
File "/usr/local/lib/python2.7/subprocess.py", line 522, in call
return Popen(*popenargs, **kwargs).wait()
File "/usr/local/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/usr/local/lib/python2.7/subprocess.py", line 1335, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
I am puzzled,as the man manual says that:
-H The -H (HOME) option sets the HOME environment variable to the homedir of the target user (root by default) as specified in passwd(5). By default, sudo
does not modify HOME (see set_home and always_set_home in sudoers(5)).
,which is cited from linux manual.
The -H option just sets the HOME environment variable to the homedir of the target user as specified in passwd.
However i specified "/home/git" as homedir for git user in my /etc/passwd file.
apache:x:48:48:Apache:/var/www:/sbin/nologin
git:x:100:101:git version control:/home/git:/bin/bash
duanduan:x:101:500::/home/duanduan:/bin/bash
But why i still got this message? or was incorrect my comprehension of the description in manual?
Append for comments:
And it seems like before with specifying a absolute path.Maybe, it's not the cause.
sudo -H -u git gitosis-init < /home/git/id_rsa.pub
Traceback (most recent call last):
File "/usr/local/bin/gitosis-init", line 9, in <module>
load_entry_point('gitosis==0.2', 'console_scripts', 'gitosis-init')()
File "/usr/local/lib/python2.7/site-packages/gitosis-0.2-py2.7.egg/gitosis/app.py", line 24, in run
return app.main()
File "/usr/local/lib/python2.7/site-packages/gitosis-0.2-py2.7.egg/gitosis/app.py", line 38, in main
self.handle_args(parser, cfg, options, args)
File "/usr/local/lib/python2.7/site-packages/gitosis-0.2-py2.7.egg/gitosis/init.py", line 138, in handle_args
user=user,
File "/usr/local/lib/python2.7/site-packages/gitosis-0.2-py2.7.egg/gitosis/init.py", line 75, in init_admin_repository
template=resource_filename('gitosis.templates', 'admin')
File "/usr/local/lib/python2.7/site-packages/gitosis-0.2-py2.7.egg/gitosis/repository.py", line 63, in init
close_fds=True,
File "/usr/local/lib/python2.7/subprocess.py", line 522, in call
return Popen(*popenargs, **kwargs).wait()
File "/usr/local/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/usr/local/lib/python2.7/subprocess.py", line 1335, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
I guess it is because ~ is expanded by bash before transferring to sudo as a argument, why not try to specify a absolute path for you public key file?

Resources