简体   繁体   中英

How to import mailbox module from python2.5 if I also have installed python2.6 and python3.1 on my machine?



I have a small problem with python and with the import of a module: I want to use the mailbox module from python2.5 but the problem is that I also have installed python2.6 and python3.1 on my machine and when the program reaches the line import mailbox the following error is raised (it`s only the final part of the error):
File "/usr/lib/python2.6/mailbox.py", line 19, in import email.message ImportError: No module named message

How can I force the app to import the mailbox module from /usr/lib/python2.5?

Thanks in advance for your help!

使用适当的可执行文件运行它。

python2.5 somescript.py

I am working under windows and i do not know wether it is working under linux.

you may use .pth files that you can place somewhere you can import modules from. if message.py is in a path called /usr/lib/python2.5/message.py you can use this pth file:

message.pth

/usr/lib/python2.5

place it somewhere from where you can import eg /usr/lib/python2.6 or /usr/lib/python3.1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM