Building Python and more on missing modules

后端 未结 1 659
心在旅途
心在旅途 2020-12-04 08:28

I have another thread asking help on \"missing zlib\". With the nice help the problem has been resolved (almost).

Now I am interested in building Python myself (on U

相关标签:
1条回答
  • 2020-12-04 09:04

    Here is how to build Python and fix any dependencies. I am assuming that you want this Python to be entirely separate from the Ubuntu release Python, so I am specifying the --prefix option to install it all in /home/python27 using the standard Python layout, i.e. site-packages instead of dist-packages.

    1. Get the .tar.gz file into your own home directory.
    2. tar zxvf Py*.tar.gz
    3. cd Py*1
    4. ./configure --prefix=/home/python27
    5. make
    6. make install
    

    Step 5 is the important one. At the end, it will display a list of any modules that could not be built properly. Often you can fix this by installing an Ubuntu package, and rerunning make.

    a. sudo apt-get install something-dev
    b. make
    

    It is pretty common to have a problem because you are missing the -dev addon to some module or other. But sometimes you should start over like this:

    a. make clean
    b. ./configure --prefix=/home/python27
    c. make
    

    Starting over never hurts if you are unsure. An important note about step 6. I am not using sudo on this command which means that you will need to have the /home/python27 directory already created with the appropriate ownership.

    Don't hesitate to try out ./configure --help |less before building something because there may be interesting options that you could use. One time on a minimal distro I had to do --with-dbmliborder=gdbm:bdb in order to get gdbm working. When you run ./configure, the last few lines will tell you where it put the information that it learned. In the case of Python, Modules/Setup has been useful to figure out how to get a module to build.

    Another useful thing is to make clean and then run make >make.out 2>&1 to capture all the output from the full make process. Then, after it is complete, use less or an editor to look for the details on a problem module such as _sqlite. For instance, check all the -I options that are passed to gcc. If the correct include directory is not on the list that would cause a problem. You can edit setup.py to change the list of include directories.

    In the past it was more common to have library problems that would be fixed by logging out, logging in again, and running "sudo ldconfig" before doing a complete rebuild.

    0 讨论(0)
提交回复
热议问题