17

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?

baduker
  • 19,152
  • 9
  • 33
  • 56
newbie16
  • 767
  • 5
  • 13
  • 23

4 Answers4

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.

Frank-Rene Schäfer
  • 3,182
  • 27
  • 51
  • 1
    I think /usr is sufficient as prefix. – ankit tyagi Mar 24 '18 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 '18 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? – Mohamed Hafez Aug 25 '19 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
MrBean Bremen
  • 14,916
  • 3
  • 26
  • 46
  • 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. – SherylHohman May 08 '20 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.

AndyJost
  • 1,085
  • 1
  • 10
  • 18