In my ubuntu 16.04 system I have the following pyenv versions
$ pyenv versions
* system (set by /home/myuser/.pyenv/version)
3.6.0
3.6.0/envs/general
general
I intend that the version named system should coincide with the real system one, but when I check which python version will be executed, I get:
$ python --version
Python 3.6.0
$ which python # expecting /usr/bin/python
/home/myuser/.pyenv/shims/python
instead of the expected /usr/bin/python symlink which points to python2.7
$ ll /usr/bin/python
lrwxrwxrwx 1 root root 9 apr 18 10:11 /usr/bin/python -> python2.7*
Why is that? Is there something that I understand wrong?
How do I reset the pyenv system to make it coherent with the real system? I want to be sure of using the real system python when executing normal commands in my home dir.
Related
I want to install Mesos on Oracle Linux 8.3 which does not have Internet access. I followed the process exactly in its site in part CentOS 7.1 and installed some packages before building mesos. I installed these packages using rpm -i name of package:
glib2-2.56.4-156.el8.x86_64.rpm
glib2-2.56.4-8.el8.x86_64.rpm
glib2-devel-2.56.4-156.el8.x86_64.rpm
glib2-devel-2.56.4-8.el8.x86_64.rpm
libcurl-7.61.1-14.el8.x86_64.rpm
libcurl-devel-7.61.1-14.el8.x86_64.rpm
libsecret-devel-0.18.6-1.el8.x86_64.rpm
libserf-1.3.9-9.module_el8.4.0+632+d2bf8782.x86_64.rpm
pcre-8.42-4.el8.x86_64.rpm
pcre-cpp-8.42-4.el8.x86_64.rpm
pcre-devel-8.42-4.el8.x86_64.rpm
pcre-utf16-8.42-4.el8.x86_64.rpm
pcre-utf32-8.42-4.el8.x86_64.rpm
cyrus-sasl-md5-2.1.27-5.el8.x86_64.rpm
python2-2.7.15-24.el8.x86_64.rpm
python2-2.7.18-7.module_el8.5.0+894+1c54b371.x86_64.rpm
python2-devel-2.7.15-24.el8.x86_64.rpm
python2-libs-2.7.15-24.el8.x86_64.rpm
python2-libs-2.7.18-7.module_el8.5.0+894+1c54b371.x86_64.rpm
python2-pip-9.0.3-18.module_el8.4.0+642+1dc4fb01.noarch.rpm
python2-pip-wheel-9.0.3-18.module_el8.5.0+743+cd2f5d28.noarch.rpm
python2-setuptools-wheel-39.0.1-13.module_el8.5.0+743+cd2f5d28.noarch.rpm
sqlite-devel-3.26.0-11.el8.x86_64.rpm
subversion-1.10.2-4.module_el8.3.0+703+ba2f61b7.x86_64.rpm
subversion-devel-1.10.2-4.module_el8.3.0+703+ba2f61b7.x86_64.rpm
subversion-libs-1.10.2-4.module_el8.3.0+703+ba2f61b7.x86_64.rpm
utf8proc-2.1.1-5.module_el8.3.0+703+ba2f61b7.x86_64.rpm
zlib-devel-1.2.11-16.el8_2.x86_64.rpm
Also, I installed python2.7 in this way:
tar zxvf Python-2.7.15.tgz
./configure --enable-optimizations
make altinstall
After that I set its path in ~/.bashrc like this:
alias python=/usr/local/bin/python2.7
export PATH=$PATH:/usr/local/bin/python2.7
For its pip also I run this command:
python2.7 -m ensurepip --default-pip
When I run python --version it show me Python 2.7.15.
Again extract Mesos folder and create build directory, then run ../configure; but I receive the same error before installing python 2.7.15:
configure: error: Mesos requires Python < 3.0
-------------------------------------------------------------------
The detected Python version is 3.6.
If you already have Python 2.6+ installed (and it's the default python on the path), you might want to check if you have the PYTHON environment variable set to a version of Python greater than 3.0.
However, when I run python command and receive this result which show that python 2.7.15 is default, mesos recognize python 3.6:
Python 2.7.15 (default, Sep 10 2022, 16:33:49)
Output of printenv:
LD_LIBRARY_PATH=/opt/oracle/instantclient_21_4:/opt/oracle/instantclient_21_4:/opt/oracle/instantclient_21_4:
LS_COLORS=rs=0:di=38;5;33:ln=38;5;51:mh=00:pi=40;38;5;11:so=38;5;13:do=38;5;5:bd=48;5;232;38;5;11:cd=48;5;232;38;5;3:or=48;5;232;38;5;9:mi=01;05;37;41:su=48;5;196;38;5;15:sg=48;5;11;38;5;16:ca=48;5;196;38;5;226:tw=48;5;10;38;5;16:ow=48;5;10;38;5;21:st=48;5;21;38;5;15:ex=38;5;40:*.tar=38;5;9:*.tgz=38;5;9:*.arc=38;5;9:*.arj=38;5;9:*.taz=38;5;9:*.lha=38;5;9:*.lz4=38;5;9:*.lzh=38;5;9:*.lzma=38;5;9:*.tlz=38;5;9:*.txz=38;5;9:*.tzo=38;5;9:*.t7z=38;5;9:*.zip=38;5;9:*.z=38;5;9:*.dz=38;5;9:*.gz=38;5;9:*.lrz=38;5;9:*.lz=38;5;9:*.lzo=38;5;9:*.xz=38;5;9:*.zst=38;5;9:*.tzst=38;5;9:*.bz2=38;5;9:*.bz=38;5;9:*.tbz=38;5;9:*.tbz2=38;5;9:*.tz=38;5;9:*.deb=38;5;9:*.rpm=38;5;9:*.jar=38;5;9:*.war=38;5;9:*.ear=38;5;9:*.sar=38;5;9:*.rar=38;5;9:*.alz=38;5;9:*.ace=38;5;9:*.zoo=38;5;9:*.cpio=38;5;9:*.7z=38;5;9:*.rz=38;5;9:*.cab=38;5;9:*.wim=38;5;9:*.swm=38;5;9:*.dwm=38;5;9:*.esd=38;5;9:*.jpg=38;5;13:*.jpeg=38;5;13:*.mjpg=38;5;13:*.mjpeg=38;5;13:*.gif=38;5;13:*.bmp=38;5;13:*.pbm=38;5;13:*.pgm=38;5;13:*.ppm=38;5;13:*.tga=38;5;13:*.xbm=38;5;13:*.xpm=38;5;13:*.tif=38;5;13:*.tiff=38;5;13:*.png=38;5;13:*.svg=38;5;13:*.svgz=38;5;13:*.mng=38;5;13:*.pcx=38;5;13:*.mov=38;5;13:*.mpg=38;5;13:*.mpeg=38;5;13:*.m2v=38;5;13:*.mkv=38;5;13:*.webm=38;5;13:*.ogm=38;5;13:*.mp4=38;5;13:*.m4v=38;5;13:*.mp4v=38;5;13:*.vob=38;5;13:*.qt=38;5;13:*.nuv=38;5;13:*.wmv=38;5;13:*.asf=38;5;13:*.rm=38;5;13:*.rmvb=38;5;13:*.flc=38;5;13:*.avi=38;5;13:*.fli=38;5;13:*.flv=38;5;13:*.gl=38;5;13:*.dl=38;5;13:*.xcf=38;5;13:*.xwd=38;5;13:*.yuv=38;5;13:*.cgm=38;5;13:*.emf=38;5;13:*.ogv=38;5;13:*.ogx=38;5;13:*.aac=38;5;45:*.au=38;5;45:*.flac=38;5;45:*.m4a=38;5;45:*.mid=38;5;45:*.midi=38;5;45:*.mka=38;5;45:*.mp3=38;5;45:*.mpc=38;5;45:*.ogg=38;5;45:*.ra=38;5;45:*.wav=38;5;45:*.oga=38;5;45:*.opus=38;5;45:*.spx=38;5;45:*.xspf=38;5;45:
LC_MEASUREMENT=az_IR
M2_HOME=/usr/local/maven
SSH_CONNECTION=x.x.x.x 57648 xx.xx.xx.xx 22
LC_PAPER=az_IR
LC_MONETARY=az_IR
LANG=en_US.UTF-8
HISTCONTROL=ignoredups
HOSTNAME=kr311
OLDPWD=/root/Downloads/mesos/mesos-1.11.0
JAVA_HOME=/opt/oracle/java/jdk1.8.0_25
S_COLORS=auto
LC_NAME=az_IR
XDG_SESSION_ID=2
USER=root
PYSPARK_HOME=/usr/bin/python3.8
SELINUX_ROLE_REQUESTED=
PWD=/root/Downloads/mesos/mesos-1.11.0/build
SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass
HOME=/root
SSH_CLIENT=x.x.x.x 57648 22
SELINUX_LEVEL_REQUESTED=
XDG_DATA_DIRS=/root/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:/usr/share
LC_ADDRESS=az_IR
SPARK_HOME=/opt/spark
LC_NUMERIC=az_IR
SSH_TTY=/dev/pts/0
MAIL=/var/spool/mail/root
TERM=xterm-256color
SHELL=/bin/bash
SELINUX_USE_CURRENT_RANGE=
PYSPARK_DRIVER_PYTHON=python3.8
SHLVL=1
LC_TELEPHONE=az_IR
LOGNAME=root
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/0/bus
XDG_RUNTIME_DIR=/run/user/0
PYSPARK_PYTHON=/usr/bin/python3.8
PATH=/opt/oracle/instantclient_21_4:/opt/oracle/java/jdk1.8.0_25/bin:/opt/oracle/instantclient_21_4:/usr/local/bin/python2.7:/opt/oracle/java/jdk1.8.0_25/bin:/opt/oracle/instantclient_21_4:/opt/oracle/java/jdk1.8.0_25/bin:/usr/local/maven/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/usr/local/bin/python2.7:/opt/spark/bin:/opt/spark/sbin:/root/bin:/opt/spark/bin:/opt/spark/sbin:/usr/local/bin/python2.7:/opt/spark/bin:/opt/spark/sbin
LC_IDENTIFICATION=az_IR
HISTSIZE=1000
LESSOPEN=||/usr/bin/lesspipe.sh %s
LC_TIME=az_IR_=/usr/bin/printenv
Would you please guide me what is wrong here?
Any help is really appreciated.
Any yum command I try to run, returns the following:
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:
cannot import name Errors
Please install a package which provides this module, or
verify that the module is installed correctly.
It's possible that the above module doesn't match the
current version of Python, which is:
2.6.6 (r266:84292, Aug 18 2016, 15:13:37)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)]
If you cannot solve this problem yourself, please go to
the yum faq at:
http://yum.baseurl.org/wiki/Faq
This is what I've done and what I know:
OS is Red hat 4.4.7018
I believe Python was 2.6 and was updated to 2.7 some time ago (I suspect this might have broken yum)
python -V returns 2.7.13
# ls -lrt /usr/bin/python*
-rwxr-xr-x. 1 root root 4864 Aug 18 2016 /usr/bin/python2.6
lrwxrwxrwx. 1 root root 6 Mar 8 13:16 /usr/bin/python2 -> python
lrwxrwxrwx. 1 root root 24 Mar 8 13:32 /usr/bin/python -> /usr/local/bin/python2.7
# ls /usr/bin/python*
/usr/bin/python /usr/bin/python2 /usr/bin/python2.6
# ls /usr/local/bin/python*
/usr/local/bin/python2.7 /usr/local/bin/python2.7-config
I've tried running import yum on all phytons and only the 2.6 does not give me an error, so I tried changing the links back to 2.6 (Validated with python -V to check it goes back to version 2.6.6), and yum still returns the "cannot import name Errors" error.
Also, the PATH variable:
# echo $PATH
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/git/bin:/root/bin
The python configured on /usr/bin/yum is #!/usr/bin/python2.6, I've tried changing it to /python, and even /phyton2 and I still get the error.
the yum command in old version of red hat(6 and older) work with python 2.6
are you test yum command with unlink /usr/bin/python and add new link from /bin/python to /usr/bin/python2.6 ?
if the result is like same error try to recompile python6 OR update your yum pkgs on server
I'm not a Linux expert, but this looks like Red Hat 6 (which had python 2.6 as default) [1]. The 4.4 is the version of GCC. When you've got python 2.6 back in place and still need Python 2.7, then install the latter via the Software Collections channel - this will install 2.7 alongside the 2.6 version and not replace it to mess up the OS.
[1] How to confirm RedHat Enterprise Linux version?
[2]https://developers.redhat.com/products/softwarecollections/hello-world/#fndtn-python
I'm having a strange problem with a virtualenv I've created for python 3. I went through the usual steps:
$ virtualenv --python=/opt/local/bin/python3.3 .py3
$ source .py3/bin/activate
The problem I'm having is that when I call python --version, it is still reporting 2.7.5, even though the paths all appear to be set up correctly. My virtualenv was created in /Users/barry.flinn/projects/.py3/bin, and I get thes results when I run which python:
$ which python
/Users/barry.flinn/projects/.py3/bin/python
The bin folder has the following python executables:
lrwxr-xr-x 1 barry.flinn obfuscated\Domain Users 9 Sep 23 19:39 python -> python3.3
lrwxr-xr-x 1 barry.flinn obfuscated\Domain Users 9 Sep 23 19:39 python3 -> python3.3
-rwxr-xr-x 1 barry.flinn obfuscated\Domain Users 9100 Sep 23 19:39 python3.3
Clearly, invoking python should give me python 3.3, and yet it still seems to revert to the system python, which is 2.7.5. My $PATH when the virtualenv is active is:
/Users/barry.flinn/projects/.py3/bin:/usr/local/mysql/bin:/opt/local/lib/postgresql92/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/go/bin:/usr/local/munki
Since all of this seems correct, I'm stumped as to what is going on here.
Update:
This reports correctly:
$ env python --version
Python 3.3.2
Which, to me, is slightly more baffling.
If you have a shell alias defined for the python interpreter, it will override the python chosen for your virtualenv. For example:
user#x790:~/temp$ alias python=/usr/bin/python
user#x790:~/temp$ python --version
Python 2.7.4
user#x790:~/temp$ virtualenv --python=/usr/bin/python3 foo
Running virtualenv with interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in foo/bin/python3
Also creating executable in foo/bin/python
Installing distribute.................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................done.
Installing pip................done.
user#x790:~/temp$ . foo/bin/activate
(foo)user#x790:~/temp$ python --version
Python 2.7.4
Note that the python version reported was 2.7.4, even though python3 was selected for the virtualenv. Using the env command circumvents the alias:
(foo)user#x790:~/temp$ env python --version
Python 3.3.1
Lastly, you can get around this issue by either temporarily disabling the python alias for a single command or permanently undefining it:
(foo)user#x790:~/temp$ \python --version
Python 3.3.1
(foo)user#x790:~/temp$ unalias python
(foo)user#x790:~/temp$ python --version
Python 3.3.1
I'm trying to get python3 working and all setup while keeping the python2 libraries in tact (system dependencies and all that).
I've installed Python3.3 (compiled, etc..) and its in /usr/bin/Python3 side by side with /usr/bin/Python2.x
Entering 'python' will take me to a 2.6 IDE and 'python3' or 'python3.3' does nothing. I'm just a little confused, I'm not sure why this isn't working at the moment.
I can actually call it with /usr/bin/python3/bin/python3 and it works. This doesn't look too pretty though, what should I do here?
$ pwd
/usr/bin/python3/bin
$ ls
2to3 idle3.3 python3 python3.3m pyvenv
2to3-3.3 pydoc3 python3.3 python3.3m-config pyvenv-3.3
idle3 pydoc3.3 python3.3-config python3-config
$ cat /proc/version
Linux version 2.6.34.7-56.40.amzn1.i686 (mockbuild#build-31003.build) (gcc version 4.4.4 20100525 (Red Hat 4.4.4-5) (GCC) ) #1 SMP Fri Oct 22 18:48:33 UTC 2010
The first thing that comes to mind is that python3 didn't automatically export its path. I think that adding
export PATH="/usr/bin/python3/bin:$PATH"
to .bash_profile or .bashrc and restarting terminal could do the trick.
I am new to linux (Ubuntu) and python (Django). By default there is python 2.6.6 in my linux, I installed python 2.7. In the command prompt when I type python it goes to python 2.6.6, I want to change my default python to 2.7.
Ubuntu might have a Python2.7 package. If so, install that then use that to create a virtualenv and put Django inside that.
I recommend to use pythonbrew which can install and switch between multi Python interpreters in your $HOME without touch your system directories.
BTW, when install python, use the command
pythonbrew install --no-test 2.7.2
to skip unitest could speed up the installation a lot.
It's all about the links, I tell ya. Look at the links. Check the inode's link count for python2.5, python2.6, python2.7, python3.2, etc. Notice those are greater than one.
Just hunt down the duped link to "python", fix by unlink, and relink it. It may be a real link, or just a sym link. unlink with extreme prejudice.
-rwxr-xr-x 2 root admin 12392 Oct 4 2009 /opt/local/bin/python2.5*
-rwxr-xr-x 2 root wheel 12392 Jul 23 17:14 /opt/local/bin/python2.6*
lrwxr-xr-x 1 root wheel 72 Nov 7 2008 /usr/bin/python# -> ../../System/Library/Frameworks/Python.framework/Versions/2.5/bin/python
-rwxrwxr-x 1 root admin 41476 Jul 3 2010 /Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7*
-rwxr-xr-x 3 root wheel 2072216 Jul 27 19:34 /usr/local/bin/python3.2*
The easiest way would be to modify your path and make sure the path to Python 2.7 is before Python 2.6. This is what I have done on my Mac to achieve similar things.
EDIT
I agree with Noufal Ibrahim in the fact about using virtualenv. I would also suggest looking into virutalenv wrapper. However, you still might have trouble using Python 2.7 is your path is not configured correctly, using an Ubuntu package for the install should take care of the path for you. Otherwise to install virtualenv from the bash shell, you can do something along the lines.
$ path/to/python27/python easy_install virutalenv
$ pip install virtualenvwrapper
I believe when installing virtualenv, it will set your PATH for you. You can confirm this by doing:
$which python
This should now show Python 2.7.