18

I downloaded python 3.6 installation file (tgz file).

I installed it the following way:

$ ./configure
$ make
$ su root
Password: 
$ make install

Then, python installed in /usr/local/bin but I want to install python in /usr/bin.

How can I do that?

2
  • Have you tried pyenv?
    – G_M
    Jun 17, 2017 at 3:32
  • No, I haven't. Although using pyenv can be an one way, I want to install python in /usr/bin directly.
    – newbie16
    Jun 17, 2017 at 3:37

4 Answers 4

15

There should be an option '--prefix' so that

> ./configure --prefix=/usr
> make
> sudo make install

should do the job. Otherwise, search for 'usr/local/bin' in the configuration script and replace accordingly.

3
  • 1
    I think /usr is sufficient as prefix. Mar 24, 2018 at 15:59
  • 1
    the prefix must be /usr otherwise it will create a new /lib inside the bin folder! Edit your answer please!
    – Peshmerge
    Apr 30, 2018 at 11:24
  • After doing this, packages that depend on python like apt-listchanges fail with errors like ImportError: No module named apt_pkg. any idea how to get the new installation to recognize those modules, or be compiled with those modules? Aug 25, 2019 at 22:53
3

You can change the location using the --prefix option in configure (which defaults to usr/local). Python will be installed under /bin, so if you want it in /usr/bin, you can write:

./configure --prefix=/usr  --enable-optimizations
make
make install
1
  • 1
    While this code may resolve the OP's issue, it is best to include an explanation as to how your code addresses the OP's issue. In this way, future visitors can learn from your post, and apply it to their own code. SO is not a coding service, but a resource for knowledge. Also, high quality, complete answers are more likely to be upvoted. These features, along with the requirement that all posts are self-contained, are some of the strengths of SO as a platform, that differentiates it from forums. You can edit to add additional info, or links to documentation. May 8, 2020 at 16:15
2

This following commands worked for me :

./configure --prefix=/usr
make
make install
0

Building Python with optimizations can take some time. If this has already been done and you wish to avoid repeating it, you might consider the following:

sudo make install prefix=/usr

I don't know whether going rerunning ./configure will force a rebuild.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.