0

I am running a CentOS 7.2 system, and I recently used pyenv to install Python 2.7.5. I am rather new to Linux, and I was under the impression that I should use pyenv to install Python so as not to interfere with the "system Python." Before installing pyenv, yum worked perfectly.

Now, however, when I try to use yum I get the following error:

There was a problem importing one of the python modules required to run yum. The error leading to the problem was: No module named yum. Please install a package which provides this module, or verify that the module is installed correctly.

I tried following the advice from the first reply of this post. When I type find / -type f -executable -name 'python2*', I get the following output:

~/.pyenv/shims/python2

~/.pyenv/shims/python2.7

~/.pyenv/shims/python2.7-config

~/.pyenv/shims/python2-config

~/.pyenv/shims/versions/2.7.5/bin/python2.7

~/.pyenv/shims/versions/2.7.5/bin/python2.7-config

~/.pyenv/shims/versions/2.7.5/envs/spyderenv/bin/python2.7

/usr/bin/python2.7

/usr/bin/python2.7 should clearly be the system Python, but when I run it and type 'import yum', I get ImportError: No module named yum. (And just to cover my bases, the first line of the 'yum' file is #!/usr/bin/python, and /usr/bin/python is a link to python2, and python2 is a link to python2.7)

It seems that somehow pyenv is screwing things up, but I can't figure out how. Thanks in advance for the help.

Community
  • 1
  • 1
dyson
  • 93
  • 8
  • Look inside your `pyvenv.cfg` file and check if `include-system-site-packages` is set to `true`. – VPfB Dec 17 '16 at 20:06
  • Hmmm...I do not appear to have a pyvenv.cfg file. Using the 'find' command, the closest I have appears to be .pyenv/plugins/pyenv-virtualenv/test/pyvenv.bats. There are no other files beginning with 'pyvenv' appearing in my .pyenv directory or subdirectories. – dyson Dec 17 '16 at 22:07
  • I'm sorry, I made a pyenv vs. py**v**env mistake. Did you use the `--system-site-packages` switch when crating the virtual env? http://stackoverflow.com/questions/3371136/revert-the-no-site-packages-option-with-virtualenv – VPfB Dec 18 '16 at 08:35
  • I did not use the `--system-site-packages` switch. I uninstalled my old environment, then issued the command `pyenv virtualenv --system-site-packages myenv`. Unfortunately I still cannot find any file named `pyenv.cfg`. – dyson Dec 19 '16 at 15:41
  • Hmmm...I just discovered that the system Python for CentOS 7.2 is version 2.7.5. I did not know that originally (I thought it was 2.6.x), and so I used pyenv to install Python 2.7.5 as well. Perhaps this is contributing to my problem? – dyson Dec 19 '16 at 15:44
  • As I wrote `pyvenv.cfg` was a mistake. Don't search for that file. There are two different programs with very similar name: pyvenv and pyenv. The former uses that `cfg` file, but you have the latter. Again, sorry for the confusion. Anyway, if `--system-site-packages` did not help, I'm afraid I have no other ideas. – VPfB Dec 19 '16 at 17:41
  • All right, this isn't a complete answer, but I did figure out that if I comment out lines defining PYTHONPATH, LD_LIBRARY_PATH, C_INCLUDE_PATH, and CPLUS_INCLUDE_PATH in my .bashrc file, yum starts working again. At this point I am going to ditch pyenv and just use system python. – dyson Dec 19 '16 at 21:33

0 Answers0