在缺少的模块上构建Python等 [英] Building Python and more on missing modules

查看:133
本文介绍了在缺少的模块上构建Python等的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有另一个线程在缺少zlib"方面寻求帮助.有了很好的帮助,问题几乎得以解决.

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

现在,我有兴趣自己构建Python(在Ubuntu 10.10上).

Now I am interested in building Python myself (on Ubuntu 10.10).

一些重要的问题引起了我的注意:

A few important questions have caught my attention:

  1. 在构建Python(例如2.7.1)之后,如果缺少模块,是否需要重新构建Python?

  1. After building Python (say 2.7.1), do I need to rebuild Python if I have missing modules?

有没有一种方法可以在构建Python之前找出缺少的模块?说sqlite3.我已为系统默认值(Python 2.6.6)安装了sqlite3,并且可以将其导入Python 2.6.6 shell中.现在,我使用pythonbrew来构建2.7.1,并且在外壳程序中我无法导入sqlite3,因为_sqlite3不可用.我确信还有一些更重要的内容需要我将来开发(例如Django ..).

Is there a way to find out what modules will be missing prior to building Python? Say sqlite3. I have sqlite3 installed for the system default (Python 2.6.6), and I can import that into Python 2.6.6 shell. Now I use pythonbrew to build 2.7.1, and in the shell I cannot import sqlite3 because _sqlite3 is not available. I am sure there are a few more important one missing which I need for future development (such as Django..).

我愿意学习如何在不使用 pythonbrew 的情况下进行构建.

I am willing to learn how to build without using pythonbrew.

请与我分享您在构建另一个版本的Python方面的经验,您将如何解决缺少模块的问题?是否有构建Python的实用解决方案?

Please share with me your experience in building another version of Python, and how would you address the problem of missing modules? Is there a practical solution to building Python?

我从来没有为自己建造一个房子而烦恼,所以请忍受我.我开始意识到学习和建立自己的重要性!非常感谢你!

I have never bothered building one myself, so please bear with me. I am beginning to realize the importance of learning and building one myself! Thank you very much!

编辑

首先,我感谢您的所有投入.他们意义重大.我做了建筑.

First I thank you all of your inputs. They meant a lot. I did the building.

Python build finished, but the necessary bits to build these modules were not found:
_bsddb             _curses            _curses_panel   
_tkinter           bsddb185           bz2             
dbm                gdbm               readline        
sunaudiodev        _sqlite3                                    
To find the necessary bits, look in setup.py in detect_modules() for the module's name.

我得到了sqlite3并读完了

I got sqlite3 and readline away by

sudo apt-get install libreadline6 libreadline6-dev
sudo apt-get install libsqlite3-dev

我尝试导入它们,但是仍然没有命名模块xxxx".

I tried to import them, but still "no named module xxxx".

AskUbuntu 上,我实际上问过人们如何获取以前的命令,因为我无法使用该功能当我使用Python 2.7.1 shell时.我相信这是由于readline. 阅读热线

At AskUbuntu I actually asked people how to get previous commands because I couldn't use that feature when I am in Python 2.7.1 shell. I believe it's due to readline. Readline

我在以下目录下安装了Python-2.7.1:/home/jwxie518/python27/

I installed the Python-2.7.1 under this directory: /home/jwxie518/python27/

我查看了setup.py,发现了以下几行:

I looked into setup.py, I found the following lines:

# The sqlite interface
sqlite_setup_debug = False   # verbose debug prints from this script?

# We hunt for #define SQLITE_VERSION "n.n.n"
# We need to find >= sqlite version 3.0.8
sqlite_incdir = sqlite_libdir = None
sqlite_inc_paths = [ '/usr/include',
                     '/usr/include/sqlite',
                     '/usr/include/sqlite3',
                     '/usr/local/include',
                     '/usr/local/include/sqlite',
                     '/usr/local/include/sqlite3',
                   ]

上面列出的所有路径都不存在. 所以我想我必须手动安装sqlite3吗?我在此处(不过是中文)

All the paths listed above do not exist. So I guess I have to install sqlite3 manually? I got another reference here (it's in Chinese, however)

# Download the latest and extract
# Go into the extracted directory
./configure --prefix=/home/jwxie518/python27/python
make && make install
# Then edit python-2.7 's setup.py before rebuild it
# Sample (add these two lines to the end....)
'~/share/software/python/sqlite-3.6.20/include',
'~/share/software/python/sqlite-3.6.20/include/sqlite3',

# Then rebuild python like how we did before

我进入了安装sqlite3的目录.我只找到了 include/sqlite3.h .因此,我回过头来检查/usr/include/.我也只能找到sqlite3.h.

I went into my directory where I installed sqlite3. I found include/sqlite3.h only. So I went back and check /usr/include/. I can only find sqlite3.h too.

那么这是怎么回事? Readline也不重要.

So what is going on here? Readline is also non-importable.

3RD编辑 我重新开始了一切,只是没有重新安装sqlite3.

3RD EDIT I started everything over, except I didn't reinstall sqlite3.

# Extract Python-2.7.1
# cd into Python-2.7.1
# ./configure
make >make.out 2>&1
less make.out

make.out在这里: http://pastebin.com/raw.php?i= 7k3BfxZQ

make.out is here: http://pastebin.com/raw.php?i=7k3BfxZQ

我仍然无法导入sqlite3.所以我进入setup.py并进行了更改:

I still couldn't import sqlite3. So I went into setup.py and made changes:

# We hunt for #define SQLITE_VERSION "n.n.n"
# We need to find >= sqlite version 3.0.8
sqlite_incdir = sqlite_libdir = None
sqlite_inc_paths = [ '/usr/include',
                     '/usr/include/sqlite',
                     '/usr/include/sqlite3',
                     '/usr/local/include',
                     '/usr/local/include/sqlite',
                     '/usr/local/include/sqlite3',
                     '/home/jwxie518/python-mod/include/sqlite',
                     '/home/jwxie518/python-mod/include/sqlite3',
                   ]

然后再次运行所有内容(这次我也做了清理)

Then again, ran everything over (this time I also did make clean)

输出在这里: http://pastebin.com/raw.php?i=8ZKgAcWn

根据输出,我认为不包括自定义路径....(有关完整输出,请转到上面的链接并搜索sqlite)

According to the output, I don't think the custom path is included.... (for complete output please go to the link above and search for sqlite)

build/temp.linux-i686-2.7/home/jwxie518/Python-2.7.1/Modules/_sqlite/util.o -L/usr/lib -L ​​/usr/local/lib -Wl,-R/usr/lib -lsqlite3 -o build/lib.linux-i686-2.7/_sqlite3.so

build/temp.linux-i686-2.7/home/jwxie518/Python-2.7.1/Modules/_sqlite/util.o -L/usr/lib -L/usr/local/lib -Wl,-R/usr/lib -lsqlite3 -o build/lib.linux-i686-2.7/_sqlite3.so

我仍然无法导入sqlite3.

I still cannot import sqlite3.

谢谢!

非常感谢Michael Dillon,帮助我.您的教程简洁明了.

Thank you very much, Michael Dillon, for helping me out. Your tutorial was neat and clear.

我在尝试使用Python-2.7.1时一意识到就解决了这个问题,实际上我正在使用Pythonbrew安装的那个.

I solved the problem as soon as I realized whenever I tried Python-2.7.1, I was actually using the one installed by Pythonbrew.

故事的寓意被读懂了所有的错误.我忽略了导入sqlite3所产生的错误. Pythonbrew安装的一个没有安装sqlite3.在SQLbrew安装Python-2.7.1之后安装了sqlite3的开发包.

The moral of the story is read all the errors. I neglected the errors generated by importing sqlite3. The one installed by Pythonbrew didn't have sqlite3 installed. The development package for sqlite3 was installed after Pythonbrew installed the Python-2.7.1

谢谢.

推荐答案

以下是构建Python和修复所有依赖项的方法.我假设您希望此Python与Ubuntu版本的Python完全分开,所以我指定--prefix选项,以使用标准Python布局将其全部安装在/home/python27中,即使用site-packages而不是dist-包.

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

第5步很重要.最后,它将显示无法正确构建的所有模块的列表.通常,您可以通过安装Ubuntu软件包并重新运行make来解决此问题.

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

有一个问题很常见,因为您缺少某些模块或其他模块的-dev插件.但是有时您应该像这样重新开始:

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

如果您不确定,从头开始不会有任何伤害.关于步骤6的重要说明.我在此命令上未使用sudo,这意味着您将需要已经使用适当的所有权创建了/home/python27目录.

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.

在构建某些东西之前不要犹豫尝试./configure --help |less,因为您可能会使用一些有趣的选项.为了使gdbm正常运行,我不得不在一个最小的发行版上做一次--with-dbmliborder = gdbm:bdb.当您运行./configure时,最后几行将告诉您它将所学信息放在何处.对于Python,Modules/Setup有助于找出如何构建模块.

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.

另一个有用的事情是make clean,然后运行make >make.out 2>&1来捕获整个制造过程中的所有输出.然后,完成后,使用less或编辑器在问题模块(例如_sqlite)上查找详细信息.例如,检查传递给gcc的所有-I选项.如果正确的包含目录不在列表中,将导致问题.您可以编辑setup.py更改包含目录的列表.

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.

过去,更常见的问题是通过完全注销来解决库问题,方法是先注销,重新登录并运行"sudo ldconfig".

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.

这篇关于在缺少的模块上构建Python等的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆