python related error reports [SOLVED]

Quick to answer questions about finding your way around Linux Mint as a new user.
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions use the other forums in the support section.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
agvares

python related error reports [SOLVED]

Post by agvares »

i'm just getting familiar with the whole linux structure and linux shell particularly.

something I can't still understand is this reports I keep getting whenever my command fails.

for example, if I open shell and type "mk dir ~/work/articles", I get the following:

Code: Select all

Traceback (most recent call last):
  File "/usr/lib/command-not-found", line 23, in <module>
    import gettext
  File "/usr/local/lib/python3.3/gettext.py", line 49, in <module>
    import locale, copy, io, os, re, struct, sys
  File "/usr/local/lib/python3.3/struct.py", line 12, in <module>
    from _struct import *
ImportError: No module named '_struct'
why is that so and what does it actually mean?

for that I have no idea at all.

thanks in advance for any clarification on the issue
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
xenopeek
Level 25
Level 25
Posts: 29510
Joined: Wed Jul 06, 2011 3:58 am

Re: python related error reports

Post by xenopeek »

"mk" is not a command ("mkdir" is), so the shell tries to run the command-not-found program, which can in most cases suggest what package you should install to get the command you are trying to run. When this works, your command should reply the following:

Code: Select all

mk: command not found
So yes, something is going wrong.

Which version of Linux Mint are you using? And what did you do with Python? Because I'm on Linux Mint 14 and that has Python version is 3.2.3 as the default Python 3 version (you have a version from the 3.3 branch).

Can you share the output of:

Code: Select all

ls -ld /usr/bin/python* /usr/local/lib/python*
Image
agvares

Re: python related error reports

Post by agvares »

xenopeek wrote:"mk" is not a command ("mkdir" is), so the shell tries to run the command-not-found program
yeah, I know that, just used the wrong spelling to demonstrate how inadequate my error reports are
xenopeek wrote:Which version of Linux Mint are you using?
Mint 14 "Nadia"
xenopeek wrote:And what did you do with Python? Because I'm on Linux Mint 14 and that has Python version is 3.2.3 as the default Python 3 version (you have a version from the 3.3 branch)
it's not that I did anything except for installing the 3rd version (since i'm reading a textbook on the version 3.3)
xenopeek wrote:Can you share the output
sure, here it is:

Code: Select all

lrwxrwxrwx  1 root root        9 февр.  8 19:20 /usr/bin/python -> python2.7
lrwxrwxrwx  1 root root        9 февр.  8 19:20 /usr/bin/python2 -> python2.7
-rwxr-xr-x  1 root root  2655776 сент. 27 02:42 /usr/bin/python2.7
lrwxrwxrwx  1 root root        9 февр.  8 19:20 /usr/bin/python3 -> python3.2
lrwxrwxrwx  1 root root       11 февр.  8 19:20 /usr/bin/python3.2 -> python3.2mu
-rwxr-xr-x  1 root root  2863832 окт.  20 00:11 /usr/bin/python3.2mu
lrwxrwxrwx  1 root root       11 февр.  8 19:20 /usr/bin/python3mu -> python3.2mu
drwxrwsr-x  4 root staff    4096 окт.  17 18:59 /usr/local/lib/python2.7
drwxrwsr-x  3 root staff    4096 окт.  17 18:56 /usr/local/lib/python3.2
drwxr-xr-x 34 root root     4096 февр.  8 21:35 /usr/local/lib/python3.3
User avatar
xenopeek
Level 25
Level 25
Posts: 29510
Joined: Wed Jul 06, 2011 3:58 am

Re: python related error reports

Post by xenopeek »

Okay so this is weird, you have the library files for Python 3.3 but no executables. Only Python 3.2... The plot thickens! :D

Might be that you didn't install all the needed packages. Can you check with:

Code: Select all

dpkg -l | grep $'python3\.'
For only Python 3.2 installed, it shows the packages

Code: Select all

ii  libpython3.2                                3.2.3-6ubuntu3.1                          amd64        Shared Python runtime library (version 3.2)
ii  python3.2                                   3.2.3-6ubuntu3.1                          amd64        Interactive high-level object-oriented language (version 3.2)
ii  python3.2-minimal                           3.2.3-6ubuntu3.1                          amd64        Minimal subset of the Python language (version 3.2)
For Python 3.3 you should have each of these packages also. Perhaps you installed Python 3.3 from Synaptic? That by default doesn't install the package's recommended other packages, while apt-get and Software Manager both do this. So if you used Synaptic, you should be aware that most of the time you are crippling yourself. It may still have another cause though :D Let's see which python3 packages you have.
Image
agvares

Re: python related error reports

Post by agvares »

xenopeek wrote:Let's see which python3 packages you have
seems you were right:

Code: Select all

ii  libpython3.2                                                3.2.3-6ubuntu3.1                          amd64        Shared Python runtime library (version 3.2)
ii  python3.2                                                   3.2.3-6ubuntu3.1                          amd64        Interactive high-level object-oriented language (version 3.2)
ii  python3.2-minimal                                           3.2.3-6ubuntu3.1                          amd64        Minimal subset of the Python language (version 3.2)
but i really don't remember which method i've used to install python3.3
User avatar
xenopeek
Level 25
Level 25
Posts: 29510
Joined: Wed Jul 06, 2011 3:58 am

Re: python related error reports

Post by xenopeek »

Okay, let's check. What does this give:

Code: Select all

dpkg -S python3.3
Image
agvares

Re: python related error reports

Post by agvares »

xenopeek wrote:Okay, let's check. What does this give:

Code: Select all

dpkg -S python3.3
it gives me:

Code: Select all

dpkg-query: warning: parsing file '/var/lib/dpkg/status' near line 38948 package 'pdfstudio':
 mo description
libobasis4.0-pyuno: /opt/libreoffice4.0/program/libpython3.3m.so
moreover, i've reinstalled python3 using apt-get, and now I don't see any message at all after entering non-existent commands, which kinda worries me a bit
agvares

Re: python related error reports

Post by agvares »

i've just learned an important lesson:

Code: Select all

apt-get remove python3
may destroy my system, and it did destroy it.

going for reinstall, I suppose.

any insights on how that could happen?
User avatar
xenopeek
Level 25
Level 25
Posts: 29510
Joined: Wed Jul 06, 2011 3:58 am

Re: python related error reports

Post by xenopeek »

Lots of system tools use Python 3 or Python 2.7, which is why I always think please don't touch Python as you will get yourself in trouble :| But you can safely install Python 3.3 alongside these other versions if you need 3.3. At least I have confirmed that the following command will install it properly and not cause the issues you described:

Code: Select all

apt install python3.3 libpython3.3
Now, if you want to make a Python 3.3 script you just start it with:

Code: Select all

#!/usr/bin/env python3.3
Do not try to make Python 3.3 your default Python or Python 3 interpreter, or you will get yourself in trouble again. Leave the default Python interpreters be, as those are needed by system software...
Image
agvares

Re: python related error reports

Post by agvares »

xenopeek wrote:don't touch Python as you will get yourself in trouble
i'll remember that for sure

thanks for help

ps. i didn't quite get what you've said about Synaptics.

doesn't it install all the required packages as well? it sure seems like it's doing so whenever I try to install or remove anything.
Locked

Return to “Beginner Questions”