Have problem in fabric When updating sudo apt - python

I'm trying to make a script that installs python on my VPS's automatically using Fabric library, But it gives me an error when I do this sudo command:
server.sudo("apt -y update")
and it says bash: sudo: command not found.
I hope I made the problem clear.

Related

Conversion of HTML to PDF using wkhtmltopdf failed

For setup I ran:
sudo apt-get install wkhtmltopdf
pip install pdfkit==0.6.1
Now, I am trying to run the following code on a VM in the cloud:
import pdfkit
pdfkit.from_file("foo.html", "foo.pdf", options={"javascript-delay": 10000})
The javascript-delay argument is necessary because otherwise some parts are not rendered correctly. This command works fine on my local machine, but in the cloud I get the following error message:
wkhtmltopdf exited with non-zero code 1. error:
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
qt.qpa.screen: QXcbConnection: Could not connect to display
Could not connect to any X display.
Any idea how to fix this error OR ideas about an alternative way of converting an .html to a .pdf?
After a lot of trial and error, this is what I added to my Dockerfile to make it work:
RUN apt-get update && apt-get install -yq gdebi
RUN TEMP_DEB="$(mktemp).deb" \
&& wget -O "$TEMP_DEB" 'https://github.com/wkhtmltopdf/packaging/releases/download/0.12.1.4-2/wkhtmltox_0.12.1.4-2.bionic_amd64.deb' \
&& sudo apt install -yqf "$TEMP_DEB" \
&& rm -f "$TEMP_DEB"
So basically installing gdebi and then installing a different version of wkhtmltox.

Tkinter install in docker

I have a docker file that installs all the dependencies and creates an environment for the application, but there is one particular one that is giving me a hard time.
I am using this command to install tkinter in docker container
RUN apt-get install -y python3-tk
But this one gives a prompt to select for time zones and geography.
I am currently circumventing this by getting in the docker and install the same in container with
docker run -ti tag:latest /bin/sh
which isn't very neat, is there a way around this one, Either to do one of the following
Auto select the prompt (with something like expect and send)
Install tkinter without prompt maybe defaults.
Any suggestions that are not complete answers for similar problems are appreciated as well, we can also install it in a different way if possible without apt
I had the same problem, and I used this in my Dockerfile:
ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=Europe/London
RUN apt-get install -y python3-tk
This is based on this answer: How to install tzdata on a ubuntu docker image?

Homebrew/Python errors after trying to install Certbot

I'm trying to install Certbot on my macOS machine (10.14.4) to generate a certificate, but as usual, some Homebrew errors are standing in the way.
After running, brew update and brew install certbot, I tried a command based on sudo certbot certonly -a manual -d example.com --email your#email.com, but I get sudo: certbot: command not found. I also tried brew upgrade.
brew doctor shows:
Warning: The following directories do not exist:
/usr/local/sbin
You should create these directories and change their ownership to your account.
sudo mkdir -p /usr/local/sbin
sudo chown -R $(whoami) /usr/local/sbin
Warning: You have unlinked kegs in your Cellar.
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
python#2
python
brew link python returns Linking /usr/local/Cellar/python/3.7.3... Error: Permission denied # dir_s_mkdir - /usr/local/Frameworks.
For some reason, it looks like I have 2 versions of Python installed now and I don't want to run any of the commands that Homebrew suggests until I know I need to. python --version returns Python 2.7.10.
Should I uninstall one of my Pythons? Is one of them the system version or is that a third installation somewhere else? Which one should I symlink and how do I get the certbot command working? Thanks in advance
sudo mkdir /usr/local/Frameworks
sudo chmod 1777
then
brew link python3
this will install your python3 on your mac
i would not deinstall python 2.7 because there are still a lot of scripts depends on python 2.7!

Getting "sudo: command not found" error in bitbucket-pipelines

In my bitbucket-pipelines.yml file, I have this:
- step:
image: python:3.7.2-stretch
name: upload to s3
script:
- export S3_BUCKET="elasticbeanstalk-us-east-1-133233433288"
- export VERSION_LABEL=$(cat VERSION_LABEL)
- sudo apt-get install -y zip # required for packaging up the application
- pip install boto3==1.3.0 # required for upload_to_s3.py
- zip --exclude=*.git* -r /tmp/artifact.zip . # package up the application for deployment
- python upload_to_s3.py # run the deployment script
But when I run this pipeline in Bitbucket, I get an error, which the output:
+ sudo apt-get install -y zip
bash: sudo: command not found
Why would it not know what sudo means? Isn't this common to all Linux machines?
The "command not found" error is printed in stderr when it does not find the binary in the folders configured in env $PATH
first you need to found out if it exists with :
find /usr/bin -name "sudo"
if you find the binary try to set the PATH variable with :
export PATH=$PATH:/usr/bin/
then try to run sudo again.
No, sudo is not available everywhere.
But you don’t have to bother with it, anyway. When running the image, you are root, so you can simply run apt-get without spending a thought on permissions.

How to install GSSAPI Python module?

I am trying to install the GSSAPI module through pip but I receive this error that I don't know how to resolve.
Could not find main GSSAPI shared library. Please try setting
GSSAPI_MAIN_LIB yourself or setting ENABLE_SUPPORT_DETECTION to
'false'
I need this to work on Python 2.6 for LDAP3 authentication.
Summary, for the impatient
$ sudo ln -s /usr/bin/krb5-config.mit /usr/bin/krb5-config
$ sudo ln -s /usr/lib/x86_64-linux-gnu/libgssapi_krb5.so.2 /usr/lib/libgssapi_krb5.so
$ sudo apt-get install python-pip libkrb5-dev
$ sudo pip install gssapi
And now the details...
I have a Debian system that uses Heimdal Kerberos. I'll take you through what I had to do to get it working for me. Hopefully, this can help someone else as well.
Problem 1 - krb5-config: command not found
setup.py for gssapi uses the krb5-config command to find the GSSAPI library to link against (see here). Because my system was installed using Heimdal instead of MIT Kerberos, the executable command has been renamed to krb5-config.mit so setup.py misses it.
$ krb5-config --libs gssapi # doesn't work
bash: krb5-config: command not found
I created a symlink to get it to work for the install:
$ sudo ln -s /usr/bin/krb5-config.mit /usr/bin/krb5-config
$ krb5-config --libs gssapi # does work
-L/usr/lib/x86_64-linux-gnu/mit-krb5 -Wl,-z,relro -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err
Problem 2 - libgssapi_krb5.so: cannot open shared object file: No such file or directory
setup.py is looking in /usr/lib for the gssapi library to link against. In Debian Jesse, most libs are now kept in /usr/lib/x86_64-linux-gnu. Again, a symlink can fix this:
$ sudo ln -s /usr/lib/x86_64-linux-gnu/libgssapi_krb5.so.2 /usr/lib/libgssapi_krb5.so
Problem 3 - error: unknown type name ‘gss_key_value_set_desc’
The build fails because it does not recognize a symbol in the library. The reason for this is that it was not able to get the right header file. Silly me, I forgot to include the -dev package for krb5 headers. Fix this with apt-get:
$ sudo apt-get install libkrb5-dev
Finally - Install gssapi
Now we should be all ready to go.
$ sudo pip install gssapi
If you want to tidy up, you can remove the symlink to the krb5-config.mit command:
$ sudo rm /usr/bin/krb5-config
sudo apt install libkrb5-dev
actually installs /usr/bin/krb5-config and /usr/lib/libgssapi_krb5.so
so none of the symlinking was needed, just install libkrb5-dev and you should be good.
For me, the issue got resolved after installing the package "krb5-libs" in Centos.
Basically we need to have libgssapi_krb5.so file for installing gssapi.

Categories

Resources