how to revert make install and use make altinstall - python-2.7

i had followed this tutorial in other to overwrite python2.7 with python 3.4.4 and it worked very nice. Only one thing was wrong. typing python, still goes to python2.7 and python3 goes to python3.4.4. so from what i learnt is that
It is critical that you use make altinstall when you install your custom version of Python. If you use the normal make install you will end up with two different versions of Python in the filesystem both named python. This can lead to problems that are very hard to diagnose.
Please help me revert this.

went through this blog Install Python on Linux (Centos).
I had to re-run make altinstall with sudo command of course. I tried this after that
`sudo ln -s /usr/local/bin/python3.4 /usr/local/bin/python`.
which have me
ln: creating symbolic link `/usr/local/bin/python': File exists
I had to delete the path /usr/local/bin/python.
and then tried again.
problem solved

Related

ERROR when trying to build chromium on my own computer

Right now, I am tring to build Chromium on my own computer under instructions at https://chromium.googlesource.com/chromium/src/+/master/docs/linux/build_instructions.md#Build-Chromium
At first, it went smoothly. However when I run
$ autoninja -C out/Default chrome
when I run this to start build. It started. And then an error occured and the build process is terminated.
The error is
NameError: name 'unicode' is not defined" and I know it is a common error associated with the difference between python2 and python3.
However, I don't know how to let the ninja use only python2 and avoid this bug.
If you can help me, I will really appreciate it.
I recently ran into this issue when attempting to home build the Brave browser, which is chromium based. It appears that chromium build is based on python2, which is fine, but uses plain calls to "python" in the scripts. Obviously, essentially all modern distros put a symlink to python3 at python in the PATH (generally /usr/bin/python -> /usr/bin/python3). I still retain hope that there is a way to configure the "python path" in the build system, but have not found it and I am not too familiar with ninja.
The first way I "solved" this, and managed a successful build is one I consider a hack and do not recommend as a solution without the stipulation that it leaves your system broken so don't run too many other things. This is to manually temporarily update the symlink. Assuming you have both /usr/bin/python2 and /usr/bin/python3 on your system, remove the symlink at /usr/bin/python and replace it with one to python2:
sudo rm /usr/bin python
sudo ln -s /usr/bin/python2 /usr/bin/python
You can then run the chromium build, and reverse the above change when completed. Note that anything on your system that requires python3 to be at the symlink python cannot be run during this time. I have successfully used this technique to build Brave (and then reverse the change after the build completed).
I can offer you some other options too. One is to set up pyenv. If you search for that, you will find it is a suite that allows you to manage multiple python versions and have different directories use different ones. I researched this, and assume it can work, but have not done it myself.
The next option, which I am currently undertaking right now, is basically a manual watered down version of what pyenv does. I will let you know how it goes. The essence is to add a symlink in the path that will redirect python calls for that instance of the shell (and all subshells it creates). Assuming you are in the source directly at the obvious path:
mkdir .shims
ln -s /usr/bin/python2 .shims/python
export PATH=/home/yourname/src/Chromium/.shims:$PATH
python --version
This should print out whatever version of python2 you have rather than python. Anytime you come back to work here, you have to export the new PATH again. The rest of your system is unaffected, and still finds python3 at python. You can open up a new terminal and type python --version to verify that.
I have Chromium building on Fedora 33. Somewhere in the Chromium build, /usr/bin/python is getting run explicitly. On Fedora, that means Python 3.
If you change /usr/bin/python to point to python2.7, I bet your build will work.
Creating aliases for "python" won't work.
If this works, consider using the alternatives command to easily change /usr/bin/python:
alternatives command for /usr/bin/python

New point of view: pip dealing with multiple Python versions, Canopy, Anaconda on Linux

Using pip with different Python version is a common problem, as I see when I search the Internet. There are a lot of answers around, also in this forum. However nobody seems to encounter the same problem that I have:
I use Canopy python most and it was installed first. Later I installed Anaconda. Now when I try to install a program with pip it always install it in Canopy (or refuse to install it because it is already installed in Canopy.
for example:
$ pip install ipython
gives:
Requirement already satisfied...
but there are no ipython in my Anaconda-folder, it is in the /Enthought/Canopy_64bit/... folder
How can I overcome this problem?
Both versions are 2.7 and even if one is 2.7.11 and the other 2.7.12, it did not work to distinguish between the two by this.
Maybe you can try the following.
Find where both pip-s reside (whereis pip, I have it on ~/anaconda2/bin), then cd to the pip directory of the python version you want, and execute it from there.
I manage with the help of J. Corson comment:
When you want to use a particular Python installation, activate the desired environment. In my chase
source /home/per/anaconda_ete/bin/activate
then using pip made the installation in the anaconda python and I could install ipython and other stuff there... fine, thanks!

Python site-packages and corresponding interpreter

I used brew to install python 2.7 and 3.5 on Mac. SOMEHOW I have this site-packages directory /usr/local/lib/python2.7/site-packages.
But every python interpreter on the system points to every other site-packages directory EXCEPT this one. How do I use THIS site-packages directory?
(This is all because I need Vips. I'd installed this before, but now I'm using a different machine and I can't figure out how on Earth I got it to work before.)
The vips docs have a checklist and an explanation of what happens when Python tried to import vips:
http://www.vips.ecs.soton.ac.uk/supported/current/doc/html/libvips/using-from-python.html
But briefly you need to:
You have several Pythons installed, make sure you are invoking the brew one.
Make sure that that Python has a gi repository containing the Vips.py overrides.
Make sure you have a Vips-8.0.typelib file in /usr/local/lib/lib/girepository-1.0/.
SOLVED.
I didn't want to have to resort to resetting my dev box to factory settings, but I did. I hope this helps somebody...
If Python already exists on your system, and you're planning on installing Python yourself or with Homebrew (because you only get python2.7 out of the box), make sure you install the new Python first. Then put the install location first in your PATH. Then install your modules. In that order. I knew something was wrong, so I uninstalled Python/3 and Vips. But when I reinstalled them, for whatever reason Vips still didn't know to bind itself to the Python in /usr/local/Cellar. Even though I had /usr/local/Cellar first in PATH.
So to recap -- first install Homebrew, then set the PATH, then install python/python3, and finally install Vips. And you're good to go.

How to use -pip- to install packages that can work with Anaconda?

I am trying to install some additional packages that do not come with Anaconda. All of these packages can be installed using pip install PackageName. However, when I type this command at the Anaconda Command Prompt, I get the following error:
Fatal error in launcher: Unable to create process using '"C:\Python27\python.exe
" "C:\python27\scripts\pip.exe" install MechanicalSoup'
I also tried to run the command from the python interpreter after import pip but that also did not work (I got a SyntaxError: invalid syntax).
I am a noob and understand that this might be a very basic question so thanks for your help in advance!
PS: I am using Windows 7, 64 bit, conda version: 3.7.1 and python version: 2.7.6.
When installing anaconda, you are asked if you want to include the installed python to your system PATH variable. Make sure you have it in your PATH. If everything is set up correct, you can run pip from your regular command prompt aswell.
Using #heinzchr's and #mmann's suggestions I was able to piece together the problem. I already had a version of Python 2.7 saved at C:\Python27 and I had to remove this from the Path (My Computer's properties> Advanced system settings> System variables> Path). I can now use pip install from the command line.
There is a way around the use of pip
From the anaconda terminal window you can run:
conda install PackageName
Because MechanicalSoup isn't in one of anaconda's package channels you will have to do a bit of editing
See instructions near the bottom on their blog
For those looking for Python packages not added to current channels in anaconda, try https://conda-forge.org/ For example, if you want to install MechanicalSoup you'll find it at https://anaconda.org/conda-forge/mechanicalsoup and use the -c option to tell conda the channel to use:
conda install -c conda-forge mechanicalsoup

Uninstall python.org version of python2.7 in favor of default OS X python2.7

I'm running OS X 10.8.2 and I believe that by default this comes with Python 2.7.3. I previously had Python 2.7.2 installed from python.org and would like to scrap it to basically reset my system's default python to that which comes pre-installed. The reason being that whenever I launch any *.py file IDLE refuses to open (even when specifying my installed Python2.7.2 IDLE) and I want to get things up to date.
Although I never use it, I do have MacPorts installed and I'm seeing that it did a bunch of stuff to my Python path - notably changing my Python 2.7 path to "/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}", so I don't know if this makes a difference.
Can anybody recommend a course of action here? I'm happy to provide additional information if needed.
There are three things making up the python.org python install which need to be removed. These steps worked for me:
Remove the actual Python install:
rm -rf /Library/Frameworks/Python.framework
Remove the Python.org extra applications by deleting the folder at /Applications/Python 2.7:
rm -rf /Applications/Python\ 2.7
Remove the symlinks to the python executables from your /usr/local/bin directory:
find /usr/local/bin -type l -and -lname "/Library/Frameworks/Python.framework*" -delete
Remove or comment out these lines from your bash startup script (either ~/.profile or ~/.bash_profile):
# Setting PATH for Python 2.7
# The orginal version is saved in .profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH
Some of these steps may require super-user privileges via e.g. sudo. Once this is done, you should have only the original Mac.
Based on documentation at http://docs.python.org/2/using/mac.html