My server is running CentOS 5.8 and uses PYTHON 2.4
I installed an alternate version of PYTHON 2.7 to use to install node.js
I have followed several different tutorials to get to this point and need a little help to finish
i am in the node directory and used this command for configure
/usr/bin/env python2.7 ./configure
when I ran the make command there was an error.
File "../../tools/js2c.py", line 387
except Error as e:
^
SyntaxError: invalid syntax
make[1]: *** [/root/node/out/Release/obj/gen/libraries.cc] Error 1
make[1]: Leaving directory `/root/node/out'
make: *** [node] Error 2
I believe that's because it's using the 2.4 version of python. How can I force the make and make install command use my alternate install of python 2.7?
I'm a complete beginner to linux commands.
I accomplished this by doing the following. Full process
yum update -y
yum -y groupinstall "Development Tools"
installed git ... followed this (https://stackoverflow.com/a/8327476/888640)
Installed alternate version of PYTHON
wget http://www.python.org/ftp/python/2.7.2/Python-2.7.2.tgz
tar -xvzf Python-2.7.2.tgz
cd Python-2.7.2
./configure
make altinstall
cd
use the correct python version
mv /usr/bin/python /usr/bin/python.old
ln -s /usr/local/bin/python2.7 /usr/bin/python
install node
cd node
./configure
make
make install
change back to normal version of python
mv /usr/bin/python.old /usr/bin/python
Related
I have the problem that when I run my code on a linux server I get:
ModuleNotFoundError: No module named '_sqlite3'
So after researching, I found out sqlite3 was supposed to have been installed when I installed python, however it didn't.
I think the problem comes from the way I installed python. Since I do not have sudo permissions, I installed python3.7 in a local directory using: This guide.
All solutions to this sqlite3 problem that I can find requires sudo commands.
Is there another way that I can install python3.7 together with sqlite3 in my local Linux directory without using any sudo commands?
I hope I have stated my question clearly and I would appreciate all the help I can get. Thank you!
While installing a python package in a Linux system without "sudo" privileges you can use
For Python 3
pip3 install --user pysqlite3
You can install any third party packages with the same method
pip3 install --user PACKAGE_NAME
The --user flag to pip install tells Pip to install packages in some specific directories within your home directory. For more information click here.
Hope it helps !
The solution is to first build sqlite3 into a user directory and then build python using that directory's libraries and include headers. In particular, #Ski has answered a similar question regarding python 2, which can be adopted to python 3:
$ mkdir -p ~/applications/src
$ cd ~/applications/src
$ # Download and build sqlite 3 (you might want to get a newer version)
$ wget http://www.sqlite.org/sqlite-autoconf-3070900.tar.gz
$ tar xvvf sqlite-autoconf-3070900.tar.gz
$ cd sqlite-autoconf-3070900
$ ./configure --prefix=~/applications
$ make
$ make install
$ # Now download and build python 2, same works for python 3
$ cd ~/applications/src
$ wget http://www.python.org/ftp/python/2.5.2/Python-2.5.2.tgz
$ tar xvvf Python-2.5.2.tgz
$ cd Python-2.5.2
$ ./configure --prefix=~/applications
$ make
$ make install
$ ~/applications/bin/python
Alternatively, if you already have to specify a different --prefix for some reason (this has happened to me with pyenv), use LDFLAGS and CPPFLAGS when configuring python build:
$ ./configure LDFLAGS=-L/home/user/applications/lib/ CPPFLAGS=-I/home/user/applications/include/
I'm trying to build Python 3.6.4 from LFS 8.2-systemd so I run the configure command:
./configure --prefix=/usr \
--enable-shared \
--with-system-expat \
--with-system-ffi \
--with-ensurepip=yes
followed by make -j.
However, at this point the module "pyexpat" is not found by Python, but the file exists in /usr/lib/libexpat.so.
After reading building Python from source with zlib support, I created a symlink:
ln -s /usr/lib /usr/lib/x86_64-gnu-linux
If i run make install, I get an error:
ModuleNotFoundError: No module named pyexpat
My expat lib version is 2.2.5.
I'm doing the compilation inside env -i chroot /mnt bash
and my environment just contains a valid PATH and LX_ALL=POSIX variables.
I ran into this same problem for python 3.6.8 , when I initially configured using:
./configure --prefix=/opt/python-3.6/ --enable-optimizations
However, when I retried using the command in the BLFS book:
./configure --prefix=/opt/python-3.6/ --enable-shared --with-system-expat --with-system-ffi --with-ensurepip=yes
My pyexpat started working.
That being said, I think it may be helpful to just retry, since my second command is functionally identical to yours.
sudo add-apt-repository ppa:jonathonf/python-3.6
sudo apt-get update
sudo apt-get install python3.6
To make python3 use the new installed python 3.6 instead of the default 3.5 release, run following 2 commands:
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.5 1
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 2
Finally switch between the two python versions for python3 via command:
sudo update-alternatives --config python3
After selecting version 3.6:
python3 -V
I am new in centos.I am try to do an application on it.For my application I need to install python 2.7.But the default one on server was python 2.6. So tried to upgrade the version .And accidentally I deleted the folder /usr/bin/python.After that I Installed python 2.7 through make install.I created the folder again /usr/bin/python and run command sudo ln -s /usr/bin/python2.7 /usr/bin/python. After this when I tried to run YUM commands I am getting the error
-bash: /usr/bin/yum: /usr/bin/python: bad interpreter: Permission denied
drwxrwxrwx 2 root root 4096 Mar 8 00:19 python
this is permission showing for the directory /usr/bin/python
CentOS requires that /usr/bin/python be pointed to Python 2.6, not any other version. Run the following commands:
sudo rm -rf /usr/bin/python
sudo ln -s /usr/bin/python2.6 /usr/bin/python
to at least fix that part of it. Next time you're building Python, use the defaults and install it to /usr/local/bin, not /usr/bin. That's what the /usr/local hierarchy is for - user-installed programs. /usr and /usr/bin should only be for system-installed programs (such as those installed by yum or its graphical equivalents), and you should keep out unless you know what you're doing. To use identically-named programs in /usr/local/bin instead of their counterparts in /usr/bin, open your ~/.bashrc or ~/.bash_profile (whichever your system uses) and add the following as the last line:
export PATH=/usr/local/bin:$PATH
Restart your shell session, and you should be all set.
yum doesn't work with python2.7.
You should do the following
vim /usr/bin/yum
change
#!/usr/bin/python
to
#!/usr/bin/python2.6
If your python2.6 was deleted, then reinstall them and point the directory in /usr/bin/yum to your python2.6 directory.
It is very simple; because the Python package was removed, the yum command won't work.
Please use below link to install packages:
Go to Link and download python package
wget http://mirror.centos.org/centos/7/sclo/x86_64/rh/python27/python27-1.1-26.1.el7.x86_64.rpm
rpm -ivh python27-1.1-26.1.el7.x86_64.rpm
Then yum will work.
this problem is that yum file start head write #!/usr/local/bin/python2.6, write binary file, is not dir, is python binary file
Resolution for CentOs 7:
dnf reinstall python-2.7.5-92.el7_9.x86_64
dnf reinstall yum
Remove python3 first using dnf if it is installed already.
-bash: /usr/bin/yum: /usr/bin/python: bad interpreter: Permission denied then
first remove python follow command line
-- sudo rpm -e python
second check which package install this command line
-- sudo rpm -q python
then install package
-- sudo yum install python*
i think this problem solve
I followed these instructions on my RedHat Linux version 7 server (which originally just had Python 2.6.x installed):
beginning of instructions
install build tools
sudo yum install make automake gcc gcc-c++ kernel-devel git-core -y
install python 2.7 and change default python symlink
sudo yum install python27-devel -y
sudo rm /usr/bin/python
sudo ln -s /usr/bin/python2.7 /usr/bin/python
yum still needs 2.6, so write it in and backup script
sudo cp /usr/bin/yum /usr/bin/_yum_before_27
sudo sed -i s/python/python2.6/g /usr/bin/yum
sudo sed -i s/python2.6/python2.6/g /usr/bin/yum
should display now 2.7.5 or later:
python -V
end of instructions
The above commands and comments were taken from:
http://www.lecloud.net/post/61401763496/install-update-to-python-2-7-and-latest-pip-on
The python -v command returned this:
-bash: python: command not found
Now it is as if I have no Python installed. I don't want yum to break. I tried installing Python 3.4.
whereis python shows this:
python: /usr/bin/python2.6 /usr/bin/python2.6-config /usr/bin/python /usr/lib/python2.6 /usr/lib64/python2.6 /usr/local/bin/python2.7 /usr/local/bin/python3.4m-config /usr/local/bin/python2.7-config /usr/local/bin/python3.4 /usr/local/bin/python3.4m /usr/local/lib/python2.7 /usr/local/lib/python3.4 /usr/include/python2.6 /usr/share/man/man1/python.1.gz
What should I do now? I want a working installation of Python. For certain things I'm doing, I need it to be 2.7 or higher. I want yum to still work.
Do
sudo update-alternatives --remove-all python
sudo ln -sf /usr/bin/python2.7 /usr/bin/python
I got the same issue while upgrading ubuntu 18 to 19, this made it:
sudo rm /usr/bin/python
sudo ln -s /usr/bin/python2.7 /usr/bin/python
do-release-upgrade
From:
https://bugs.launchpad.net/ubuntu/+source/ubuntu-release-upgrader/+bug/1825655
For me, nothing worked except this one:
unlink /usr/bin/python3
ln -s /usr/bin/python3.7 /usr/bin/python3
Credit: https://josephgeis.dev/2020/04/upgrading-to-ubuntu-20-04-python3/
This is easily fixed by installing the python27 package via yum. It should install in /usr/bin, and may overwrite the /usr/bin/python symlink that should be pointing to 2.6. If it did (just run ls -l python* in /usr/bin to see), remove the symlink and point it back to 2.6. Next create a symlink for /usr/local/bin/python pointing at /usr/bin/python2.7. Finally, modify your ~/.bashrc or ~/.bash_profile (whichever you use) to have /usr/local/bin before /usr/bin in your PATH:
export PATH=/usr/local/bin:$PATH
at the very end of the file. This way, /usr/bin/python remains linked to Python 2.6, which is what the system expects, and when you run python at the command line it'll start up 2.7. You shouldn't have to make any changes to the yum script either - just blanket replacing python with python2.6 without understanding what you're doing is not a very good idea.
I'd also recommend installing Python 3.4 in /usr/local/bin if possible, where the binary will be named python3 by convention. Even if it installs in /usr/bin, you'll still have the choice of running python3 or python3.4 to specify which version you want. I work on a CentOS system that has each version of Python from 2.4 up to 3.4 installed, all in /usr/local/bin (I'm sure this was done manually, and not via yum), while the only python* in /usr/bin is 2.6. I couldn't find a python3 package for RedHat (I may not have been looking hard enough), so I'd recommend building the latest version from source (3.4.3 as of this writing). Unzip the tarball in a suitable directory, check out the README file, then, in the Python-3.4.3 directory, run ./configure --help to see what the options are, and if you need to change anything. As long as you have gcc installed, and don't need to link to any weird math libraries or anything, you should just be able to run:
./configure
make
make test
sudo make install
and it'll install to /usr/local/bin. Check the messages at the end of the make step, as it'll list any modules it wasn't able to build there. Fails usually happen because you don't have a required library installed, so look in setup.py in the base directory in the detect_modules() function (starting on line 449, and stretching all the way down to line 1564). Install both the lib and the -devel packages so you get the necessary headers.
This same process can also be followed if you want to install the latest 2.7.9, instead of RH's 2.7.5. One of the major (in my eyes) advantages of 2.7.9 is that pip is installed by default, making third-party module installation that much easier.
Good luck!
What's the best way to get the latest SHOGUN / Python modular interface (http://www.shogun-toolbox.org) installed on 12.04? I tried from source without much luck (happy to post errors); Is it possible to install the Trusty Tahr package on 12.04? https://launchpad.net/ubuntu/+source/shogun/3.1.1-1
(I am the debian maintainer of this package).
You could try to
apt-get -b source shogun
but it will give you only the core libshogun library at this very moment. There is a python package on the way (in debian) but not yet accepted and not yet in ubuntu.
https://ftp-master.debian.org/new/python-shogun_3.1.1-1.html
So you are really best of installing from source. Shogun has buildbots running on ubuntu creating a python package. So you can just copy the settings from there:
https://travis-ci.org/shogun-toolbox/shogun/jobs/18605663
Following this posts here and this instruction i did the following that worked for me to install shogun directly into my conda env. Its not the most elegant way but worked out so far.
! Take care to have swig: ie. installed apt-get install swig
! I used anaconda and the shogun python infterface - so my cmake prefix was /home/user/anaconda/
You need cmake to build shogun:
SET UP CMAKE FIRST (skip if you have cmake > 3.1)
cd /path to your installation directory
workdir=$(pwd) #i.e. your home
Download and install cmake into your home:
wget http://www.cmake.org/files/v3.1/cmake-3.1.3.tar.gz
tar xzf cmake-3.1.3.tar.gz
cd cmake-3.1.3
cmake_dir=$workdir/cmake 5 ./configure --prefix=$cmake_dir
make -j 2
make install
Export cmake to your PATH so you can use it for shogun: export
PATH=$cmake_dir/bin/:$PATH
Download and install shogun into anaconda env
wget ftp://shogun-toolbox.org/shogun/releases/3.1/sources/shogun-3.1.1.tar.bz2
tar jxf shogun-3.1.1.tar.bz2 3 cd shogun-3.1.1/
mkdir build
cd build
cmake -DPythonStatic=ON -DPythonModular=ON -DCMAKE_INSTALL_PREFIX=/home/myusername/anaconda/envs/p27/ ..
make -j2 all #four processes takes a while
make install