简体   繁体   English

Python-OpenWrt上的ImportError

[英]Python - ImportError on OpenWrt

I installed Python 2.7.3 on my OpenWrt system and when I try to import socket module, I get an ImportError. 我在OpenWrt系统上安装了Python 2.7.3,当我尝试导入套接字模块时,出现了ImportError。

File "/usr/lib/python2.7/socket.py", line 47, in <module>
import _socket
ImportError: No module named _socket

I checked if the _socket.so module was installed in the Python package and it is. 我检查了_socket.so模块是否已安装在Python软件包中。 And I also checked the PYTHONPATH, it's correct too. 我还检查了PYTHONPATH,它也是正确的。

The path of _socket.so is : /usr/lib/python2.7/lib-dynload/_socket.so _socket.so的路径是: /usr/lib/python2.7/lib-dynload/_socket.so

And this is my PYTHONPATH : 这是我的PYTHONPATH:

/usr/lib/python27.zip
/usr/lib/python2.7
/usr/lib/python2.7/plat-linux2
/usr/lib/python2.7/lib-tk
/usr/lib/python2.7/lib-old
/usr/lib/python2.7/lib-dynload
/usr/lib/python2.7/site-packages

Does anyone have an idea ? 有人有主意吗?

You may poke with the PYTHONPATH to solve it in the immediate, see How to use PYTHONPATH 您可以戳PYTHONPATH立即解决它,请参阅如何使用PYTHONPATH

But that's a hack and depending on your openwrt version / how you installed python i'd ask on specific #openwrt support channels. 但这是一个hack,我会在特定的#openwrt支持渠道上询问您的openwrt版本/安装python的方式。 BTW you are not the only one with this issue https://translate.google.com/translate?hl=en&sl=pl&tl=en&u=http%3A%2F%2Feko.one.pl%2Fforum%2Fviewtopic.php%3Fid%3D10015 顺便说一句,您不是唯一遇到此问题的人https://translate.google.com/translate?hl=zh-CN&sl=pl&tl=en&u=http%3A%2F%2Feko.one.pl%2Fforum%2Fviewtopic.php%3Fid% 3D10015

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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