Tagged: gentoo

Python: idle: no python-exec wrapped executable found in /usr/lib/python-exec

Python IDLE

IDLE is Python’s Integrated Development and Learning Environment where it allows programmers to easily write Python code. It's like a shell, you can execute a single statement or create/execute a Python script.

If you see below error message when you try to run IDLE, it's most likely you are missing tk USE flag for python.

idle: no python-exec wrapped executable found in /usr/lib/python-exec

To check if you are missing the tk USE flag, first check the python version:$ eselect python list Available Python interpreters, in order of preference: [1] python3.8 [2] python3.9 (fallback)

Also, check the system configuration file, /etc/python-exec/python-exec.conf, for python version:

FILE /etc/python-exec/python-exec.conf
... python3.8

Then, execute emerge with the following flags to see if tk USE flag was enabled originally. In below case, tk is not enabled since it's -tk.# emerge -pve world | grep -i dev-lang/python-3.8 [ebuild R ] dev-lang/python-3.8.8:3.8::gentoo USE="gdbm ipv6 ncurses readline sqlite ssl xml -bluetooth -build -examples -hardened (-libressl) -test -tk -verify-sig -wininst" 0 KiB

Disclaimer:
The information in this site is the result of my researches on the Internet and of my experiences. This information below is solely used for my purpose and may not be suitable for others.

To enable the flag, you need to re-run emerge with the tk flag.# USE=tk emerge -a dev-lang/python:3.8

After successful update, check if it's enabled by running the same command: # emerge -pve world | grep -i dev-lang/python-3.8 [ebuild R ] dev-lang/python-3.8.8:3.8::gentoo USE="gdbm ipv6 ncurses readline sqlite ssl tk xml -bluetooth -build -examples -hardened (-libressl) -test -verify-sig -wininst" 0 KiB

That's all!
-gibb

Steps for Maintaining Gentoo Server

Disclaimer:
The information in this site is the result of my researches in the Internet and of my experiences. This information below is solely used for my purpose and may not be suitable for others.

  1. # eix-sync
    This is same as below:
    root #emerge --sync
    root #cp -a /var/cache/eix/portage.eix /var/cache/eix/previous.eix
    root #eix-update
    root #eix-diff
  2. # glsa-check --list
    1. # glsa-check -t all
      When above command returns [N], execute this.
    2. # glsa-check -p $(glsa-check -t all)
      To see what packages would be emerged.
    3. # glsa-check -f $(glsa-check -t all)
      To apply the fix.
  3. # eselect news read
  4. # emerge -uUDavp --with-bdeps=y @world
    -u (--update): Updates pkgs to the best version available
    -U (--changed-use): Include installed pkgs where USE flags have changed since installation.
    -D (--deep): Forces emerge to consider the entire dependency tree of pkgs
    -a (--ask): Display what will take place
    -v (--verbose): Run in verbose mode:
    -p (--pretend): Display what *would* have been installed if -p weren't used
    --with-bdeps=y: Pull in build time dependencies that are not strictly required
    If no problems flagged in above, go to xxx
    Otherwise, fix any problem(s) flagged by the emerge --pretend, then go to #4 again.
  5. # emerge -uUDav --with-bdeps=y @world
    If any issue(s), fix them and go to #5 again.
  6. # emerge @preserved-rebuild
    Run this only if specified in output from above.
    @preserved-rebuild: Update pkgs that still use old libraries with new ones
  7. # emerge --ask --depclean
    Run this only if specified in output from above.
    --depclean: Cleans the system by removing pkgs that are not associated w/explicitly merged pkgs
  8. # dispatch-conf
    Tool that aids in merging the ._cfg0000_[name] files
  9. # eclean-dist --deep
    Clean the source files directory, /var/cache/distfiles
  10. # eix-test-obsolete
    Search for obsolete packages on the system
  11. Wait for at least 24 hours to a week or so, then go from beginning.

That's all!
-gibb

Getting HP Laser Jet Pro 200 color MFP working with Gentoo

Configuring a printer was never successful for me in the past. At one point, I was able to set it up on Slackware but when I did a test print, it came out either skewed or enlarged for some reasons. I couldn't figure out why it behaved that way, so I gave up.

Now, due to the COVID-19 pandemic, my kids are home-schooling and it had become unavoidable that I need to set up a printer on my Gentoo system. After struggling for close to a week, I finally found a way to configure it correctly and was able to print documents. For my future note, I've describe how to set it up on Gentoo.

Disclaimer:
The information in this site is the result of my researches in the Internet and of my experiences. This information below is solely used for my purpose and may not be suitable for others.

User and lp Group:

User need to be part of lp group to be able to print. If User needs to edit via cups web interface, he needs to be part of lpadmin. # gpasswd -a [USER] lp # gpasswd -a [USER] lpadmin

Configure cups:

cups need to be re-configed with zeroconf USE flag. # echo "net-print/cups zeroconf" > /etc/portage/package.use/cups # emerge --ask net-print/cups

Install hplip:

There is a Gentoo Wiki in HPLIP. To sum up, net-print/hplip needs to be installed with the snmp, static-ppds, hpijs and scanner USE flags.# echo "net-print/hplip snmp static-ppds hpijs scanner" > /etc/portage/package.use/hplip # emerge --ask net-print/hplip

Copy PPD:

PPD (PostScript Printer Description)is a file that describes the features and capabilities of the target printer. All PPD files are located in /usr/share/HP/ by default. They are gunzip'ed, so it needs to be decompressed and copied to /etc/cups/ppd/.

My printer is HP LaserJet Pro 200 color MFP M276nw. The closest PPD file I can file is hp-laserjet_200_colormfp_m276-ps.ppd.gz and that's the one I'm going to use. # cd /usr/share/ppd/HP/ # gunzip -d /usr/share/ppd/HP/hp-laserjet_200_colormfp_m276-ps.ppd.gz # cp -d hp-laserjet_200_colormfp_m276-ps.ppd /etc/cups/ppd/

Keyserver for gpg keys:

My printer needs a binary plugin for it to work according to HP's site. To install it, hp-plugin needs to be executed as a regular user with the -i option for the interactive mode.

However, it fails with error: Unable to recieve key from keyserver. This issue stumped me for a few days and I was almost about to give up installing the printer. Then I found a solution in a forum where it suggests to update one of python files with hard-coded keyserver name. Once the keyserver name was changed to something working, the installation of binary plugin went successfully.# nvim /usr/share/hplip/base/validation.py ========== ... class GPG_Verification(DigiSign_Verification): def __init__(self, pgp_site = 'pgp.mit.edu', key = 0x...) Change above where it says "pgp.mit.edu" to something working. For me, changing it to "ha.pool.sks-keyservers.net" worked. def __init__(self, pgp_site = 'ha.pool.sks-keyservers.net', key = 0x...) ... $ hp-plugin -i ... Done.

CUPS and HTTP Interface:

I tried many ways to install my printer from hp-setup with GUI and command line options but they all failed at the end, saying something like "No device found that support this feature." or "No installed printers found (or) Invalid printer device selected".

I stumbled again...

Then, I remembered that CUPS has HTTP Interface where you can add and manage printers. I was a bit skeptical about this but tried anyway.

  1. Start CUPS daemon and make it persistent after each reboot:# rc-service cupsd start # rc-update add cupsd default
  2. Go to http://localhost:631/ in a browser
  3. Go to "Administration" and click on "Add Printer"
  4. Choose "HP LaserJet 200 colorMFP M276nw (HP LaserJet 200 colorMFP M276nw)" and continue
  5. Make sure the connection is set to socket://[ip_address]|HP LaserJet 200 colorMFP M276nw and continue again
  6. Choose the correct model and also click on "Choose File" for PPD File
  7. Select the PPD file copied to /etc/cups/ppd/ and click on "Add printer"
  8. Click on "Set Default Options"
  9. Choose "Print Test Page" option from the "Maintenance" menu

If everything goes well, it starts printing a test page. If it fails for some reasons, I'd delete the printer at the step 4 and choose something else and repeat until it works.

That's all!
-gibb

Rip Music CD to flac, and More

Here is a list of commands to rip music CDs to flac, convert to mp3, and create a music CD.

Disclaimer:
The information in this site is the result of my researches in the Internet and of my experiences. This information below is solely used for my purpose and may not be suitable for others.

Ripping Music CD to flac:

# emerge --ask media-sound/abcde $ cp /etc/abcde.conf ~/.abcde.conf $ cp ~/.abcde.conf ========== ... FLACENCODERSYNTAX=flac FLACOPTS='-s -e -V -8' OUTPUTTYPE=flac ... $ abcde -o flac

Convert flac to mp3:

Here is a script or command line to convert flac files to mp3 using ffmpeg.$ for a in ./*.flac; do > < /dev/null ffmpeg -i "$a" -qscale:a 0 "${a[@]/%flac/mp3}" > done

Create Music CD:

To create a music CD from command line, we need a bit of preparation. If you need to normalize the volume of output files, you'd need to install media-sound/normalize.# emerge --ask media-sound/normalize

This will convert all files in the current directory to .wav files. I usually copy needed flac or mp3 files to /tmp and run these commands.$ for i in $( ls ); do ffmpeg -i $i $i.wav; done $ normalize -m *.wav $ cdrecord -v -fix -eject dev='/dev/sr0' -audio -pad *.wav

ffmpeg
  • -i INPUT: INPUT file(s)

normalize
  • -m: Enable mix mode
  • (-b: Enable batch mode)

cdrecord
  • -v: Increment the level of general verbosity by one
  • -fix: The disk will only be fixated
  • -eject: Eject disk after doing the work
  • dev=TARGET:Set the SCSI TARGET for the CD/DVD/Blu‐Ray-recorder
  • -audio: All subsequent tracks are written in CD-DA audio format
  • -pad: If the track is a data track, 15 sectors of zeroed data will be added to the end of this and each subsequent data track.

In case file names contain spaces, replace them with "_" (or something valid) before executing above commands.$ for f in *; do mv "$f" `echo $f | tr ' ' '_'`; done

That's all!
-gibb

LAMP Stack on Gentoo Linux

There aren't many sites showing how to configure LAMP (Linux, Apache, MariaDB, PHP) stack on Gentoo. Since I'm new to Gentoo and in need of configuring LAMP stack, I compiled the steps.

Disclaimer:
The information in this site is the result of my researches in the Internet and of my experiences. This information below is solely used for my purpose and may not be suitable for others.

Apache:

Web Server. Install apache with the threads support.# echo "www-servers/apache threads" > /etc/portage/package.use/apache # emerge --ask www-servers/apache

Then, enable global apache2 support for other applications.# nvim /etc/portage/make.conf ========== .... USE="... apache2"

Once the USE variable in /etc/portage/make.conf is modified, update the system so the changes take effect.# emerge --ask --changed-use --deep @world

Start the apache2 process and make it so that it automatically restarts after each reboot.# /etc/init.d/apache2 start # rc-update add apache2 default

Apache - Virtual Hosts

Apache Virtual Hosts allows to run multiple instances of websites using a single IP address. This is a good option for me when I work on a few websites at the same time. Create a conf file under /etc/apache2/vhosts.d/ for each website.# nvim /etc/apache2/vhosts.d/site1.conf ========== <VirtualHost *:80> ServerAdmin email@localhost DocumentRoot /home/ubyt3m3/www/site1 ServerName site1 ErrorLog /var/log/apache2/site1.err CustomLog /var/log/apache2/site1.log combined <Directory "/home/ubyt3m3/www/site1"> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory> </VirtualHost> # nvim /etc/apache2/vhosts.d/site2.conf ========== <VirtualHost *:80> ServerAdmin email@localhost DocumentRoot /home/ubyt3m3/www/site2 ServerName site2 ErrorLog /var/log/apache2/site2.err CustomLog /var/log/apache2/site2.log combined <Directory "/home/ubyt3m3/www/site2"> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory> </VirtualHost>

Restart the apache2 process to reload the config file(s).# /etc/init.d/apache2 reload

Maria DB

MariaDB is a community-developed, open source relational database management system (RDBMS). It's a fork from MySQL which's owned by Oracle. # emerge --ask dev-db/mariadb

Auto start mysql after each reboot. # rc-update add mysql default

Now, it's time to configure MariaDB. With Gentoo, this can be done with emerge --config. # emerge --config dev-db/mariadb

This will create a database and set permissions. You will set a root password during this process.

Start the mysql process.# rc-service mysql start

PHP

Set USE flags for PHP and install it.# echo "dev-lang/php cgi cjk curl exif gd mysql mysqli pdo postgres threads xslt" > /etc/portage/package.use/php # emerge --ask dev-lang/php

Then, configure apache for PHP by updating /etc/conf.d/apache2.# nvim /etc/conf.d/apache2 ========== ... APACHE2_OPTS="... -D PHP" ...

Restart the apache2 process.# /etc/init.d/apache2 restart

Verify if PHP works with Apache$ nvim /home/ubyt3m3/www/site1/index.php ========== <html> <body> <?php phpinfo(); ?> </body> </html>

It works!

Troubleshooting 403 Fobidden Error

If the steps are followed, it's not the types of errors you get, but it's good to know how to approach when it happens.

  • Check to see if the directory and file permissions are properly set.

    Directory: 0755
    File: 0644

  • The default directory index page is there. It is defined in the DirectoryIndex directive in apache's modules.d/70_mod_php.conf file.

    DirectoryIndex index.php index.html

  • The Apache website mentions that the index of a directory is handled by mod_dir. In Gentoo, its config file is in modules.d/00_default_settings.conf. Add index.php in front of index.html should allow index.php loaded automatically.

    <IfModule dir_module>
    DirectoryIndex index.php index.html index.html.var
    </IfModule dir_module>

  • Make sure the correct directory permissions are set in the Directory directive in the apache's config file.

    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted

  • Check the error file for some hints.

    tail -f [path_to_apache_error_file]

That's all!
-gibb