0

I installed Python 2.7.3 on my OpenWrt system and when I try to import socket module, I get an 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. And I also checked the PYTHONPATH, it's correct too.

The path of _socket.so is : /usr/lib/python2.7/lib-dynload/_socket.so

And this is my 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 ?

alexis.
  • 13
  • 1
  • 7

1 Answers1

0

You may poke with the PYTHONPATH to solve it in the immediate, see How to use PYTHONPATH

But that's a hack and depending on your openwrt version / how you installed python i'd ask on specific #openwrt support channels. 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

Community
  • 1
  • 1
  • I don't understand why I sould modify the PYTHONPATH. The _socket.so module is installed in a path which is set in PYTHONPATH... Yes I saw this topic too, but it doesn't bring a real answer... I also tried to install another Python version with a feed of OpenWrt and use the patches. But I can't manage to install an older version on my OpenWrt environment. – alexis. Mar 10 '15 at 10:47
  • With PYTHONPATH you can add the dir _/usr/lib/python2.7/lib-dynload/_ that contains the .so python is not finding. Are you using a trunk version of openwrt? if so better report the issue in the packages repository. – Riccardo Magliocchetti Mar 10 '15 at 11:08
  • There's already /usr/lib/python2.7/lib-dynload in PATHPYTHON. I add the same path with a / at the end and it does not work too. And I do not use a trunk version of openwrt. Ok I am going to report that. – alexis. Mar 10 '15 at 12:07