Problem with python after Upgrade to Mint 20

Greeting, well today I perform the upgrade form Mint 19.3 Cinnamon to Mint 20. I got some warning about ppa’s and continued. The upgrade seem to take a long time, something like 20-30 minutes, but otherwise seem to gone OK. I now wish I had done a clean install. (I still might do that.)


Anyway, my problem is when I issue this command at the terminal ‘sudo pip3 install py_sg ’ I get a whole page of an error message.
“Collecting py_sg
Using cached py_sg-0.11.tar.gz (2.8 kB)
Building wheels for collected packages: py-sg
Building wheel for py-sg (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-eomws4lc/py-sg/setup.py’"’"’; file=’"’"’/tmp/pip-install-eomws4lc/py-sg/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-uu8_35ri
cwd: /tmp/pip-install-eomws4lc/py-sg/
Complete output (12 lines):
running bdist_wheel
running build
running build_ext
building ‘py_sg’ extension
creating build
creating build/temp.linux-x86_64-3.8
x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.8 -c py_sg.c -o build/temp.linux-x86_64-3.8/py_sg.o
py_sg.c:12:10: fatal error: Python.h: No such file or directory
12 | #include <Python.h>
| ^~~~~~~~~~
compilation terminated.
error: command ‘x86_64-linux-gnu-gcc’ failed with exit status 1
ERROR: Failed building wheel for py-sg"

I looked and don’t have any PPA’s listed anymore. So maybe that’s the problem?
The terminal command before this was (and it looked to run correctly)
“sudo apt-get install python3-pip”
… and the the last few lines of the output was
Setting up python3-setuptools (45.2.0-1) …
Setting up python3-wheel (0.34.2-1) …
Setting up python-pip-whl (20.0.2-5ubuntu1) …
Setting up python3-pip (20.0.2-5ubuntu1) …
Processing triggers for man-db (2.9.1-1) …

2 Likes
1 Like

@Akito, looking this up corrected the command

which got me further thru my procedure. Can you tell me what lead you to this answer -or- would it just go over my head at this time?
sudo pip3 install py_sg now gave me (the last 3 lines)
“Successfully built py-sg
Installing collected packages: py-sg
Successfully installed py-sg-0.11”


My last 2 lines in my procedure are;
cd ~; wget https://raw.githubusercontent.com/evox95/wdpassport-utils/master/wdpassport-utils.py
(Which seem to work correctly.) The last Line;
sudo ~/wdpassport-utils.py -u
File “/home/easyt50/wdpassport-utils.py”, line 13
except ImportError, e:
^
SyntaxError: invalid syntax


And the first part of wdpassport-utils.py is;
#!/usr/bin/env python3
import sys
import os
import struct
import getpass
from hashlib import sha256
from random import randint
import argparse
import subprocess

try:
import py_sg
except ImportError, e:
print “You need to install the “py_sg” module.”
sys.exit(1)
Which means I got an error on the “import py_sg” ----->so I changed py_sg to py_sg.so and now I get;
sudo ~/wdpassport-utils.py.2 -u
Traceback (most recent call last):
File “/home/easyt50/wdpassport-utils.py.2”, line 11, in
import pyudev
ModuleNotFoundError: No module named ‘pyudev’
py.2 first few lines looked a bit different;
#!/usr/bin/env python3
import sys
import os
import struct
import getpass
import random
import string
from hashlib import sha256
from random import randint
import argparse
import pyudev


Trying different thing I ended up at https://github.com/crypto-universe/py_sg
but don’t understand the procedure and not sure I am on the right track.
Thanks.

2 Likes

regarding just that last section, the instructions want you to use a program git to clone all of the information in that repository. i have only used it successfully twice myself so would suggest waiting to see if someone else can help you work through the errors you posted above.

it may help to post a link to the directions you are following. this sounds like you are rebuilding that program that gives you access to encrypted (or password-protected?) external drives. being able to see the whole process instead of just the errors might point things in the right direction.

2 Likes

First result for searching

on the Duck.

This is almost always a Python fuckup. See:

Try starting the script with Python2.

3 Likes

Well @01101111, on the road to Linux I had 3 major problems to solve to have a successful system that most users do not have to deal with.
1 - Lenove laptop with a touch screen cause jumping cursor.
2 - Truecrypt to install (I did find Veracrypt as a replacement)
3 - (This problem) Western Digital encrypted disks.
For each Distro I install or test I need to solve all 3 on this PC or items 2 & 3 on other PC. So I documented the procedure that worked on Linux Mint 18.3 Cinnamon. Oh and by the way, it was the support / help of you, @Akito, @abhishek and @ElectricDandySlider that help me get these problems resolved.
Listed below is the proc that worked on Linux 18.3. I use it as a guide.
This proc worked**

sudo apt-get install python-pip python-dev lsscsi

sudo apt install python-setuptools python-wheel

sudo pip install py_sg

cd ~; wget https://raw.githubusercontent.com/evox95/wdpassport-utils/master/wdpassport-utils.py

chmod +x /home/easyt50/wdpassport-utils.py

Then
Plug in your password protected drive.
Run in terminal this command and enter password:

sudo python /home/easyt50/wdpassport-utils.py
-or-
sudo ~/wdpassport-utils.py -u

2 Likes

Thanks again for your help @Akito. I swear, I just don’t understand why Python3 worked one time and now Python2 works this time.
It almost seems like Linux Mint 19 upgraded to Python 3 and now Linux Mint 20 is back on Python2.

3 Likes

You can use this function to switch Python versions with a single command.

3 Likes

the duck :duck: knows.

3 Likes

i realize you have a method that works and i’m not trying to add more steps to anything, but i just ran through an install and thought i could answer this question. if you want to stick with what you have and ignore the rest, i would completely understand :slight_smile:

it looks like you are using a mixture of the old and new directions since a few things have changed other than using python3. the new directions from the project’s github:

Installing

You’ll need the Python 3 development headers to install this tool. On Ubuntu run:

sudo apt install python3 python3-dev python3-pip git

On other Linux distributions you may need a different command.

Then use pip3 to install the source code in this repository:

sudo pip3 install git+https://github.com/0-duke/wdpassport-utils

and install the required “py_sg” module for Python3:

sudo pip3 install --user git+https://github.com/crypto-universe/py_sg

in addition to the python3 packages, the first install group adds git which is used to install the packages in the second and third steps.

the github page also explains:

crypto-universe converted this project and the underlying SCSI interface library py_sg to Python 3.

i believe that’s probably how you came by the crypto-universe link you shared above. the third step installs that new python3 py_sg package instead of the one that gets used if you run sudo pip3 install py_sg.

2 Likes

I’m not a bit surprise. I’m not afraid of terminal commands (I know how to restore), but most of the commands I type in are on good faith. I really don’t understand an awful lot of them.
Feel free to update my proc and even add comment. I would be glad to to use it and hopefully learn from it. I been playing around with MX19 and if I fully test it out I will need to add support for WD external disks.

3 Likes

in all honesty, timeshift helped me come to a similar place of less worry or anxiety about running commands i am unfamiliar with. i do tend to check out the man page before i run something new to try and make sure i am not getting in over my head.

1 Like

these three steps worked like a charm in my mint 20 xfce vm:

sudo apt install python3 python3-dev python3-pip git
sudo pip3 install git+https://github.com/0-duke/wdpassport-utils
sudo pip3 install --user git+https://github.com/crypto-universe/py_sg

so they should work just fine for ubuntu 20 or anything based on it like mint 20 with whichever de you choose.

the first step is like the one you used before (sudo apt-get install python-pip python-dev lsscsi), but adds the installation of python3 itself and updates the other two packages to the python3 version. git is added to help with the next two steps. on ubuntu-based distros (more about mx19 later) this step also takes care of the second one you were using before (sudo apt install python-setuptools python-wheel). those packages (updated to python3 versions) were installed along with the three listed.

the second step replaces the fourth and fifth steps you had before (cd ~; wget https://raw.githubusercontent.com/evox95/wdpassport-utils/master/wdpassport-utils.py and chmod +x /home/easyt50/wdpassport-utils.py). in this step pip3 (python package installer) uses git (replacing wget) to download and install the majority of the program.

the third step uses the same process as the second to replace the third step you had before (sudo pip install py_sg) to install the final piece of the program and i believe the --user option means you don’t have to add /home/easyt50/ or ~/ when you run the program. i simply ran sudo wdpassport-utils.py and it worked.

part of the reason i made that previous post was because you had mentioned distro hopping and mx19. i was curious to see if an install was different on something debian-based so i tried it on an mx19.2 vm. it turned out that the second of these new three steps failed because python3-setuptools python3-wheel were not automatically installed with the first step. once i installed them, everything went just as easily as it had with mint 20 xfce.

so for mx 19.2 (and probably other debian-based distros, but no promises :slight_smile:) the process was these four steps:

sudo apt install python3 python3-dev python3-pip git
sudo apt install python3-setuptools python3-wheel
sudo pip3 install git+https://github.com/0-duke/wdpassport-utils
sudo pip3 install --user git+https://github.com/crypto-universe/py_sg

bonus image of nemo (on the left. thunar on the right) on mx 19.2 just because i was there and installing stuff:

2 Likes