and I used to have Python 2.7.10 . Recently I decided to install python Python 3.4.5. Unfortunately, after this decision all hell broke loose. The worst thing that happened is that python2.7.10 is unusable and fails with the following message
@linux-ifvn:~/Documents> python2.7
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>:<exec_prefix>]
ImportError: No module named site
I need python2.7 to keep some old code running. Using 2to3 conversion on it is not recommended. All of this is rather funny, since root is able to run python2.7.10 without problems. I guess that the changes are only for my local user. I know that in principle one can have both 2.7 and 3.4 on the same pc, but the question is how to do that.
No this doesn’t help at all because it misses all details.
Also, it’s probably also interesting where you installed python2 from I think, because that’s what is not working any more.
zypper se -si python*
which python2
And your repo list:
zypper lr -d
Generally speaking, there should not be a problem to install python2 and python3 at the same time (if you use the standard openSUSE packages).
I have both here two (and both work), I’m on 42.2 though, haven’t tried on 42.1.
Btw, 42.1 is out of maintenance since over a month already, so you should probably consider an upgrade anyway.
thank you for your help. I would consider updating to 42.2. But I am not sure how to do that. I would have to do some reserach. Last time I updated from 13.2 to 42.1 I had some issues with baloo, etc. I am always a bit scared of updates (bad experience with win*)
Coming back to the topic, here is the output
zypper se -si python*
S | Name | Type | Version | Arch | Repository
--+-----------------------+---------+--------------+--------+--------------------------
i | python | package | 2.7.12-23.1 | x86_64 | Main Update Repository
i | python | package | 2.7.12-23.1 | x86_64 | openSUSE-Leap-42.1-Update
i | python-CherryPy | package | 3.6.0-3.2 | noarch | Main Repository (OSS)
i | python-Jinja2 | package | 2.8-6.1 | noarch | Main Update Repository
i | python-Jinja2 | package | 2.8-6.1 | noarch | openSUSE-Leap-42.1-Update
i | python-MarkupSafe | package | 0.23-7.2 | x86_64 | Main Repository (OSS)
i | python-Pillow | package | 2.9.0-6.1 | x86_64 | Main Update Repository
i | python-Pillow | package | 2.9.0-6.1 | x86_64 | openSUSE-Leap-42.1-Update
i | python-base | package | 2.7.12-23.1 | x86_64 | Main Update Repository
i | python-base | package | 2.7.12-23.1 | x86_64 | openSUSE-Leap-42.1-Update
i | python-bottle | package | 0.12.7-5.2 | noarch | Main Repository (OSS)
i | python-cairo | package | 1.10.0-15.1 | x86_64 | Main Repository (OSS)
i | python-cffi | package | 1.1.0-6.2 | x86_64 | Main Repository (OSS)
i | python-configobj | package | 5.0.6-3.2 | noarch | Main Repository (OSS)
i | python-cryptography | package | 1.0-5.4 | x86_64 | Main Repository (OSS)
i | python-cups | package | 1.9.72-2.2 | x86_64 | Main Repository (OSS)
i | python-cupshelpers | package | 1.5.7-3.6 | noarch | Main Repository (OSS)
i | python-dateutil | package | 2.4.2-14.1 | noarch | Main Update Repository
i | python-dateutil | package | 2.4.2-14.1 | noarch | openSUSE-Leap-42.1-Update
i | python-decorator | package | 3.4.2-3.2 | noarch | Main Repository (OSS)
i | python-docopt | package | 0.6.2-5.2 | noarch | Main Repository (OSS)
i | python-enum34 | package | 1.0-2.2 | noarch | Main Repository (OSS)
i | python-gobject | package | 3.16.2-5.2 | x86_64 | Main Repository (OSS)
i | python-gobject-cairo | package | 3.16.2-5.2 | x86_64 | Main Repository (OSS)
i | python-gobject2 | package | 2.28.6-26.1 | x86_64 | Main Repository (OSS)
i | python-gtk | package | 2.24.0-15.1 | x86_64 | Main Repository (OSS)
i | python-idna | package | 2.0-2.2 | noarch | Main Repository (OSS)
i | python-ipaddress | package | 1.0.14-2.2 | noarch | Main Repository (OSS)
i | python-jedi | package | 0.9.0-2.2 | noarch | Main Repository (OSS)
i | python-kde4 | package | 4.14.3-2.11 | x86_64 | Main Repository (OSS)
i | python-kde4-akonadi | package | 4.14.3-2.11 | x86_64 | Main Repository (OSS)
i | python-kde4-doc | package | 4.14.3-2.11 | x86_64 | Main Repository (OSS)
i | python-kde4-khtml | package | 4.14.3-2.11 | x86_64 | Main Repository (OSS)
i | python-kde4-knewstuff | package | 4.14.3-2.11 | x86_64 | Main Repository (OSS)
i | python-kde4-phonon | package | 4.14.3-2.11 | x86_64 | Main Repository (OSS)
i | python-kde4-plasma | package | 4.14.3-2.11 | x86_64 | Main Repository (OSS)
i | python-kdebase4 | package | 4.11.22-1.7 | x86_64 | Main Repository (OSS)
i | python-keyring | package | 5.3-4.1 | noarch | Main Update Repository
i | python-keyring | package | 5.3-4.1 | noarch | openSUSE-Leap-42.1-Update
i | python-matplotlib | package | 1.4.3-4.1 | x86_64 | Main Update Repository
i | python-matplotlib | package | 1.4.3-4.1 | x86_64 | openSUSE-Leap-42.1-Update
i | python-matplotlib-tk | package | 1.4.3-4.1 | x86_64 | Main Update Repository
i | python-matplotlib-tk | package | 1.4.3-4.1 | x86_64 | openSUSE-Leap-42.1-Update
i | python-numpy | package | 1.8.0-3.5 | x86_64 | Main Repository (OSS)
i | python-ply | package | 3.8-5.1 | noarch | Main Update Repository
i | python-ply | package | 3.8-5.1 | noarch | openSUSE-Leap-42.1-Update
i | python-pyOpenSSL | package | 0.14-5.2 | noarch | Main Repository (OSS)
i | python-pyasn1 | package | 0.1.8-9.2 | noarch | Main Repository (OSS)
i | python-pycparser | package | 2.10-5.1 | noarch | Main Repository (OSS)
i | python-pycurl | package | 7.19.0-3.2 | x86_64 | Main Repository (OSS)
i | python-pyparsing | package | 2.0.1-6.1 | noarch | Main Repository (OSS)
i | python-pyplete | package | 0.0.5-3.1 | noarch | Main Repository (OSS)
i | python-pysmell | package | 0.7.3-5.2 | noarch | Main Repository (OSS)
i | python-pytz | package | 2015.2-2.2 | noarch | Main Repository (OSS)
i | python-pyudev | package | 0.16.1-12.2 | noarch | Main Repository (OSS)
i | python-qt4 | package | 4.11.4-2.11 | x86_64 | Main Repository (OSS)
i | python-scipy | package | 0.16.0-4.6 | x86_64 | Main Repository (OSS)
i | python-setuptools | package | 18.0.1-4.1 | noarch | Main Update Repository
i | python-setuptools | package | 18.0.1-4.1 | noarch | openSUSE-Leap-42.1-Update
i | python-simplejson | package | 3.3.1-3.2 | x86_64 | Main Repository (OSS)
i | python-sip | package | 4.16.9-4.2 | x86_64 | Main Repository (OSS)
i | python-six | package | 1.9.0-5.1 | noarch | Main Repository (OSS)
i | python-smbc | package | 1.0.13-15.2 | x86_64 | Main Repository (OSS)
i | python-solv | package | 0.6.23-16.1 | x86_64 | Main Update Repository
i | python-solv | package | 0.6.23-16.1 | x86_64 | openSUSE-Leap-42.1-Update
i | python-sympy | package | 0.7.5-6.2 | noarch | Main Repository (OSS)
i | python-tk | package | 2.7.12-23.1 | x86_64 | Main Update Repository
i | python-tk | package | 2.7.12-23.1 | x86_64 | openSUSE-Leap-42.1-Update
i | python-xml | package | 2.7.12-23.1 | x86_64 | Main Update Repository
i | python-xml | package | 2.7.12-23.1 | x86_64 | openSUSE-Leap-42.1-Update
i | python3 | package | 3.4.5-8.1 | x86_64 | Main Update Repository
i | python3 | package | 3.4.5-8.1 | x86_64 | openSUSE-Leap-42.1-Update
i | python3-apparmor | package | 2.10.2-9.1 | x86_64 | Main Update Repository
i | python3-apparmor | package | 2.10.2-9.1 | x86_64 | openSUSE-Leap-42.1-Update
i | python3-base | package | 3.4.5-8.1 | x86_64 | Main Update Repository
i | python3-base | package | 3.4.5-8.1 | x86_64 | openSUSE-Leap-42.1-Update
i | python3-bottle | package | 0.12.8-3.2 | noarch | Main Repository (OSS)
i | python3-cairo | package | 1.10.0-17.1 | x86_64 | Main Repository (OSS)
i | python3-coverage | package | 3.7.1-3.3 | x86_64 | Main Repository (OSS)
i | python3-cups | package | 1.9.72-3.2 | x86_64 | Main Repository (OSS)
i | python3-dateutil | package | 2.4.2-1.3 | noarch | Main Repository (OSS)
i | python3-gedit | package | 3.16.4-1.3 | x86_64 | Main Repository (OSS)
i | python3-gobject | package | 3.16.2-5.2 | x86_64 | Main Repository (OSS)
i | python3-gobject-cairo | package | 3.16.2-5.2 | x86_64 | Main Repository (OSS)
i | python3-matplotlib | package | 1.4.3-1.8 | x86_64 | Main Repository (OSS)
i | python3-nose | package | 1.3.7-2.6 | noarch | Main Repository (OSS)
i | python3-numpy | package | 1.9.3-1.5 | x86_64 | Main Repository (OSS)
i | python3-pip | package | 7.1.2-4.5 | noarch | Main Repository (OSS)
i | python3-py | package | 1.4.30-2.3 | noarch | Main Repository (OSS)
i | python3-pycurl | package | 7.19.5.1-2.2 | x86_64 | Main Repository (OSS)
i | python3-pyparsing | package | 2.0.3-3.2 | noarch | Main Repository (OSS)
i | python3-pytz | package | 2015.6-1.1 | noarch | Main Repository (OSS)
i | python3-requests | package | 2.7.0-5.1 | noarch | Main Update Repository
i | python3-requests | package | 2.7.0-5.1 | noarch | openSUSE-Leap-42.1-Update
i | python3-scipy | package | 0.16.0-2.7 | x86_64 | Main Repository (OSS)
i | python3-setuptools | package | 18.3.2-1.1 | noarch | Main Repository (OSS)
i | python3-simplejson | package | 3.8.0-4.8 | x86_64 | Main Repository (OSS)
i | python3-six | package | 1.9.0-1.2 | noarch | Main Repository (OSS)
i | python3-smbc | package | 1.0.15.4-3.2 | x86_64 | Main Repository (OSS)
i | python3-tk | package | 3.4.5-8.1 | x86_64 | Main Update Repository
i | python3-tk | package | 3.4.5-8.1 | x86_64 | openSUSE-Leap-42.1-Update
Like wolffi323 already says, python2 en python3 can coexist on 42.2. What about reinstalling the python2 packages ?? Yet, the preferred route would be to upgrade the system to 42.2. That’s not too much of a hassle, since your repo list doesn’t contain any exotic ( read home:, devel: ) repos.
Download an installation medium from software.opensuse.org, boot from it and choose “Upgrade” (called “Offline Upgrade”)
Change your repos to the 42.2 versions and run “zypper dup” (“Online Upgrade”, as the new packages are installed while the old system is running)
The first (“offline”) variant is considered to be “safer”, but both should work fine and are continuously tested.
As you only use the standard repos (plus Packman), there’s not much to consider.
Except that you probably may have to do a full switch to Packman (the 42.2 repo) again afterwards.
As far as the eye can see, it is all open suse repositories. :\ Actually, I didn’t install python2 myself. What I had came with the OS.
Yes, and I don’t see anything wrong/missing there.
As mentioned I do have both installed without problems on 42.2, but also had on 13.2.
I very much doubt that this was not possible just in 42.1. (and I’m pretty sure there would have been complaints…)
The only thing I could imagine is that somehow some files got deleted or something like that.
Do you get any output when running this?
Well, did you maybe manually set some variable like $PYTHONHOME (to point to python3 e.g.)?
Please post the output of “env”.
I can reproduce a similar error here that way:
wolfi@linux-lf90:~> PYTHONHOME="" python2.7
ImportError: No module named site
wolfi@linux-lf90:~> python2.7
Python 2.7.13 (default, Mar 22 2017, 12:31:17) [GCC] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
PS: please also try to run python2 like this and see if that “fixes” your problem:
python2 -E
(this tells python to ignore all environment variables and e.g. use its “hardcoded” paths)
$PYTHONHOME is not set in in my case. The variable is empty. This is the output I got.
@linux-ifvn:~/Documents> python2 -E
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>:<exec_prefix>]
ImportError: No module named site
@linux-ifvn:~/Documents> PYTHONHOME="" python2.7
ImportError: No module named site
There may be other variables involved too.
That’s why I asked for the output of “env”, not the value of $PYTHONHOME.
This is the output I got.
@linux-ifvn:~/Documents> python2 -E
Could not find platform independent libraries
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to :<exec_prefix>]
ImportError: No module named site
@linux-ifvn:~/Documents> PYTHONHOME=“” python2.7
ImportError: No module named site
And what if you do set it to the correct value?
wolfi@linux-lf90:~> PYTHONHOME=/usr python2.7
Python 2.7.13 (default, Mar 22 2017, 12:31:17) [GCC] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
PYTHONHOME not being set should be fine though. It’s unset here too.
I think that I get the ide now. I have a code, which changes where python is pointing to its own local version. This action is in my bashrc. I removed it now and it seems to work fine. The version the code uses seems to be missing matploltlib…
Anyway I might consider changing to leap 42.2. Is there some good guide how to do that. I remember there was a very good explanation going from 13.2 to 42.1
Last but not least, I would like to thank you for the help and advice. You are the best.
TBH, there must be more things missing in that version, or the “code” you mention doesn’t work as intended…
A missing matplotlib definitely doesn’t break the python interpreter/cause your error message, I don’t even have it installed here in the first place.
Anyway, it seems your problem is solved now…
Anyway I might consider changing to leap 42.2. Is there some good guide how to do that. I remember there was a very good explanation going from 13.2 to 42.1