# sem_init: No space left on device + ImportError: cannot import name SSLError



## bernardomaciel (May 17, 2010)

Hello everyone,



I came across a problem when updating the port devel/py-setuptools , and then found out that the problem appears elsewhere. I tried searching but couldn't find anything that would help me... I have basic FreeBSD knowledge only. So, here goes.

When I install py-setuptools, I get


```
===>  Extracting for py26-setuptools-0.6c11
=> MD5 Checksum OK for python/setuptools-0.6c11.tar.gz.
=> SHA256 Checksum OK for python/setuptools-0.6c11.tar.gz.
===>  Patching for py26-setuptools-0.6c11
===>   py26-setuptools-0.6c11 depends on file: /usr/local/bin/python2.6 - found
===>  Configuring for py26-setuptools-0.6c11
running config
===>  Building for py26-setuptools-0.6c11
running build
running build_py
creating build
creating build/lib
copying pkg_resources.py -> build/lib
copying easy_install.py -> build/lib
copying site.py -> build/lib
creating build/lib/setuptools
copying setuptools/extension.py -> build/lib/setuptools
copying setuptools/sandbox.py -> build/lib/setuptools
copying setuptools/depends.py -> build/lib/setuptools
copying setuptools/__init__.py -> build/lib/setuptools
copying setuptools/archive_util.py -> build/lib/setuptools
copying setuptools/dist.py -> build/lib/setuptools
copying setuptools/package_index.py -> build/lib/setuptools
creating build/lib/setuptools/tests
copying setuptools/tests/test_resources.py -> build/lib/setuptools/tests
copying setuptools/tests/__init__.py -> build/lib/setuptools/tests
copying setuptools/tests/test_packageindex.py -> build/lib/setuptools/tests
copying setuptools/tests/doctest.py -> build/lib/setuptools/tests
creating build/lib/setuptools/command
copying setuptools/command/build_ext.py -> build/lib/setuptools/command
copying setuptools/command/upload.py -> build/lib/setuptools/command
copying setuptools/command/bdist_wininst.py -> build/lib/setuptools/command
copying setuptools/command/egg_info.py -> build/lib/setuptools/command
copying setuptools/command/__init__.py -> build/lib/setuptools/command
copying setuptools/command/setopt.py -> build/lib/setuptools/command
copying setuptools/command/install_egg_info.py -> build/lib/setuptools/command
copying setuptools/command/bdist_egg.py -> build/lib/setuptools/command
copying setuptools/command/install.py -> build/lib/setuptools/command
copying setuptools/command/bdist_rpm.py -> build/lib/setuptools/command
copying setuptools/command/install_lib.py -> build/lib/setuptools/command
copying setuptools/command/saveopts.py -> build/lib/setuptools/command
copying setuptools/command/develop.py -> build/lib/setuptools/command
copying setuptools/command/easy_install.py -> build/lib/setuptools/command
copying setuptools/command/build_py.py -> build/lib/setuptools/command
copying setuptools/command/install_scripts.py -> build/lib/setuptools/command
copying setuptools/command/sdist.py -> build/lib/setuptools/command
copying setuptools/command/rotate.py -> build/lib/setuptools/command
copying setuptools/command/alias.py -> build/lib/setuptools/command
copying setuptools/command/register.py -> build/lib/setuptools/command
copying setuptools/command/test.py -> build/lib/setuptools/command
copying setuptools/cli.exe -> build/lib/setuptools
copying setuptools/gui.exe -> build/lib/setuptools
===>  Installing for py26-setuptools-0.6c11
===>   py26-setuptools-0.6c11 depends on file: /usr/local/bin/python2.6 - found
===>   Generating temporary packing list
===>  Checking if devel/py-setuptools already installed
running install
sem_init: No space left on device
Traceback (most recent call last):
  File "setup.py", line 94, in <module>
    scripts = scripts,
  File "/usr/local/lib/python2.6/distutils/core.py", line 152, in setup
    dist.run_commands()
  File "/usr/local/lib/python2.6/distutils/dist.py", line 975, in run_commands
    self.run_command(cmd)
  File "/usr/local/lib/python2.6/distutils/dist.py", line 995, in run_command
    cmd_obj.run()
  File "/usr/ports/devel/py-setuptools/work/setuptools-0.6c11/setuptools/command/install.py", line 76, in run
    self.do_egg_install()
  File "/usr/ports/devel/py-setuptools/work/setuptools-0.6c11/setuptools/command/install.py", line 85, in do_egg_install
    easy_install = self.distribution.get_command_class('easy_install')
  File "/usr/ports/devel/py-setuptools/work/setuptools-0.6c11/setuptools/dist.py", line 395, in get_command_class
    self.cmdclass[command] = cmdclass = ep.load()
  File "/usr/ports/devel/py-setuptools/work/setuptools-0.6c11/pkg_resources.py", line 1954, in load
    entry = __import__(self.module_name, globals(),globals(), ['__name__'])
  File "/usr/ports/devel/py-setuptools/work/setuptools-0.6c11/setuptools/command/easy_install.py", line 21, in <module>
    from setuptools.package_index import PackageIndex, parse_bdist_wininst
  File "/usr/ports/devel/py-setuptools/work/setuptools-0.6c11/setuptools/package_index.py", line 2, in <module>
    import sys, os.path, re, urlparse, urllib2, shutil, random, socket, cStringIO
  File "/usr/local/lib/python2.6/urllib2.py", line 94, in <module>
    import httplib
  File "/usr/local/lib/python2.6/httplib.py", line 70, in <module>
    import socket
  File "/usr/local/lib/python2.6/socket.py", line 64, in <module>
    from _ssl import SSLError as sslerror
ImportError: cannot import name SSLError
*** Error code 1

Stop in /usr/ports/devel/py-setuptools.
```

Then, when I use hp-scan from print/hplip3 to scan something, I get


```
sem_init: No space left on device
Traceback (most recent call last):
  File "/usr/local/bin/hp-scan", line 37, in <module>
    import socket
  File "/usr/local/lib/python2.6/socket.py", line 64, in <module>
    from _ssl import SSLError as sslerror
ImportError: cannot import name SSLError
```

If I go to python and try to manually import SSLError, I get


```
Python 2.6.5 (r265:79063, May 15 2010, 19:22:30) 
[GCC 4.2.1 20070719  [FreeBSD]] on freebsd8
Type "help", "copyright", "credits" or "license" for more information.
>>> from _ssl import SSLError as sslerror
sem_init: No space left on device
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name SSLError
```

Here is also my system information from uname -a


```
FreeBSD FPserver.WORKGROUP 8.0-RELEASE-p2 FreeBSD 8.0-RELEASE-p2 #2: Tue Jan 26 06:10:27 WET 2010     root@FPserver.WORKGROUP:/usr/obj/usr/src/sys/NOULPTKERNEL  i386
```

Can anybody help me? Thanks!

Bernardo


----------



## gilinko (May 17, 2010)

Sounds like you have a full /usr/local slice and need to either delete some things or increase the sice of that slice. Post the output of`$ df -k`


----------



## bernardomaciel (May 17, 2010)

@gilinko : Here it is


```
Filesystem  1024-blocks     Used    Avail Capacity  Mounted on
/dev/ad0s1a      507630   126972   340048    27%    /
devfs                 1        1        0   100%    /dev
/dev/ad1s1d   116826596 59526154 47954316    55%    /media/disk1
/dev/ad3s1d    18935374  9298980  8121566    53%    /media/disk3
/dev/ad0s1e      126702     6278   110288     5%    /tmp
/dev/ad0s1f     2850254  2438230   184004    93%    /usr
/dev/ad0s1d      253678   156672    76712    67%    /var
```


----------



## gilinko (May 17, 2010)

Your /usr is close to full, as you only have 184 MB left on that slice which include your home directory(if you haven't changed that location). And during compilation that can use up quite a bit of disc you simply run out of storage space that is needed. You home dir is definitely full as the last 8% is dedicated to only root.

So you need to clean that disk from things you don't need and to be honest 2.8 GB is not enough for both all the things in /usr (ports, local etc) and your home dir (/usr/home/USERNAME).


----------



## DutchDaemon (May 17, 2010)

You can probably clean out some tarballs from /usr/ports/distfiles to begin with.


----------



## bernardomaciel (May 17, 2010)

@gilinko @DutchDaemon Thanks for the replies. I cleaned out /usr/ports/distfiles and checked out the home dirs, which take something like 14MB. Here is "df -k" now:


```
Filesystem  1024-blocks     Used    Avail Capacity  Mounted on
/dev/ad0s1a      507630   126972   340048    27%    /
devfs                 1        1        0   100%    /dev
/dev/ad1s1d   116826596 59526154 47954316    55%    /media/disk1
/dev/ad3s1d    18935374  9298980  8121566    53%    /media/disk3
/dev/ad0s1e      126702     6278   110288     5%    /tmp
/dev/ad0s1f     2850254  1562346  1059888    60%    /usr
/dev/ad0s1d      253678   156120    77264    67%    /var
```

I tried the installation of devel/py-setuptools again, running "hp-scan" and the manual python import with no luck :/ can you help?


----------



## DutchDaemon (May 17, 2010)

Ok, it's not a disk issue; it appears to be threading-related. Maybe read http://lists.unbit.it/pipermail/uwsgi/2010-February/000120.html and the thread it belongs in.

Googling for the specific string "sem_init: No space left on device" does point to specific Python (compilation/runtime) issues.


----------



## bernardomaciel (May 18, 2010)

@DutchDaemon Thanks for pointing that out. I looked at http://translate.google.com/translate?hl=en&sl=ru&u=http://bsdportal.ru/viewtopic.php%3Ft%3D21875%26postdays%3D0%26postorder%3Dasc%26start%3D20%26sid%3D488a672605643872e5c798b0241b6ea7&prev=/search%3Fq%3D%2522sem_init:%2Bno%2Bspace%2Bleft%2Bon%2Bdevice%2522%26hl%3Den%26client%3Dsafari%26rls%3Den&rurl=translate.google.com and then rebuilt lang/python26 with the HUGE_STACK_SIZE, SEM and PTH options. It seems to have solved the problem, as I could install devel/py-setuptools and do the manual SSLError import. I'm rebuilding hplip now to see if `% hp-scan` works.

Thanks!

Bernardo


----------



## bernardomaciel (May 18, 2010)

Hello again,



Aparently my actions did not solve the problem. I could not compile print/hplip after building lang/python26 with GNU pthreads (PTH option). It gives some declaration clashes.. So I tried rebuilding lang/python26 and change the options around. With the THREADS and HUGE_STACK_SIZE options, I first get the 
	
	



```
sem_init: No space left on device
```
 error when the script builds the _ssl extension.


```
(...)
===>  Building for python26-2.6.5
(...)
ranlib libpython2.6.a
cc -pthread -Wl,--export-dynamic -o python  Modules/python.o  libpython2.6.a -ldl  -lutil   -lm  
libpython2.6.a(posixmodule.o)(.text+0x765): In function `posix_tmpnam':
: warning: warning: tmpnam() possibly used unsafely; consider using mkstemp()
libpython2.6.a(posixmodule.o)(.text+0x85c): In function `posix_tempnam':
: warning: warning: tempnam() possibly used unsafely; consider using mkstemp()
running build
running build_ext
building '_struct' extension
creating build
creating build/temp.freebsd-8.0-RELEASE-p2-i386-2.6
creating build/temp.freebsd-8.0-RELEASE-p2-i386-2.6/usr
creating build/temp.freebsd-8.0-RELEASE-p2-i386-2.6/usr/ports
creating build/temp.freebsd-8.0-RELEASE-p2-i386-2.6/usr/ports/lang
creating build/temp.freebsd-8.0-RELEASE-p2-i386-2.6/usr/ports/lang/python26
creating build/temp.freebsd-8.0-RELEASE-p2-i386-2.6/usr/ports/lang/python26/work
creating build/temp.freebsd-8.0-RELEASE-p2-i386-2.6/usr/ports/lang/python26/work/Python-2.6.5
creating build/temp.freebsd-8.0-RELEASE-p2-i386-2.6/usr/ports/lang/python26/work/Python-2.6.5/Modules
cc -fPIC -fno-strict-aliasing -DNDEBUG -O2 -pipe -D__wchar_t=wchar_t -DTHREAD_STACK_SIZE=0x100000 -fno-strict-aliasing -I. -I/usr/ports
/lang/python26/work/Python-2.6.5/./Include -I. -IInclude -I./../Include -I/usr/local/include -I/usr/ports/lang/python26/work/Python-
2.6.5/portbld.static/Include -I/usr/ports/lang/python26/work/Python-2.6.5/portbld.static -c /usr/ports/lang/python26/work/Python-2.6.5/Modules
/_struct.c -o build/temp.freebsd-8.0-RELEASE-p2-i386-2.6/usr/ports/lang/python26/work/Python-2.6.5/Modules/_struct.o
creating build/lib.freebsd-8.0-RELEASE-p2-i386-2.6
cc -shared -pthread -O2 -pipe -D__wchar_t=wchar_t -DTHREAD_STACK_SIZE=0x100000 -fno-strict-aliasing build/temp.freebsd-8.0-RELEASE-p2-i386-2.6
/usr/ports/lang/python26/work/Python-2.6.5/Modules/_struct.o -L/usr/local/lib -o build/lib.freebsd-8.0-RELEASE-p2-i386-2.6/_struct.so
building '_ctypes_test' extension
creating build/temp.freebsd-8.0-RELEASE-p2-i386-2.6/usr/ports/lang/python26/work/Python-2.6.5/Modules/_ctypes
cc -fPIC -fno-strict-aliasing -DNDEBUG -O2 -pipe -D__wchar_t=wchar_t -DTHREAD_STACK_SIZE=0x100000 -fno-strict-aliasing -I. -I/usr/ports
/lang/python26/work/Python-2.6.5/./Include -I. -IInclude -I./../Include -I/usr/local/include -I/usr/ports/lang/python26/work/Python-
2.6.5/portbld.static/Include -I/usr/ports/lang/python26/work/Python-2.6.5/portbld.static -c /usr/ports/lang/python26/work/Python-2.6.5/Modules
/_ctypes/_ctypes_test.c -o build/temp.freebsd-8.0-RELEASE-p2-i386-2.6/usr/ports/lang/python26/work/Python-2.6.5/Modules/_ctypes/_ctypes_test.o
cc -shared -pthread -O2 -pipe -D__wchar_t=wchar_t -DTHREAD_STACK_SIZE=0x100000 -fno-strict-aliasing build/temp.freebsd-8.0-RELEASE-p2-i386-2.6
/usr/ports/lang/python26/work/Python-2.6.5/Modules/_ctypes/_ctypes_test.o -L/usr/local/lib -o build/lib.freebsd-8.0-RELEASE-p2-i386-2.6
/_ctypes_test.so
(...)
building '_ssl' extension
cc -fPIC -fno-strict-aliasing -DNDEBUG -O2 -pipe -D__wchar_t=wchar_t -DTHREAD_STACK_SIZE=0x100000 -fno-strict-aliasing -I. -I/usr/ports
/lang/python26/work/Python-2.6.5/./Include -I. -IInclude -I./../Include -I/usr/local/include -I/usr/ports/lang/python26/work/Python-
2.6.5/portbld.static/Include -I/usr/ports/lang/python26/work/Python-2.6.5/portbld.static -c /usr/ports/lang/python26/work/Python-2.6.5/Modules
/_ssl.c -o build/temp.freebsd-8.0-RELEASE-p2-i386-2.6/usr/ports/lang/python26/work/Python-2.6.5/Modules/_ssl.o
cc -shared -pthread -O2 -pipe -D__wchar_t=wchar_t -DTHREAD_STACK_SIZE=0x100000 -fno-strict-aliasing build/temp.freebsd-8.0-RELEASE-p2-i386-2.6
/usr/ports/lang/python26/work/Python-2.6.5/Modules/_ssl.o -L/usr/local/lib -lssl -lcrypto -o build/lib.freebsd-8.0-RELEASE-p2-i386-2.6/_ssl.so
sem_init: No space left on device
```

Then I could not do the installation of devel/py-setuptools, nor the manual import of SSLError, nor getting print/hplip utilities to work. So can this be a problem with the _ssl extension of lang/python26? Otherwise, I'm clueless :/

Can anybody help? Can somebody open the thread again? 

Thanks!

Bernardo


----------



## bernardomaciel (Jun 12, 2010)

So after:

- contacting python support, which suggested that I compiled python26 from python.org's source, which worked
- contacting python freebsd port maintainer, who suggested that



> Increase the value of the kern.ipc.shmall sysctl because you have other applications eating up POSIX shmem in the background.
> HTH,
> -Garrett



- messing around with kern.ipc sysctls without any luck, I ended up resorting to pkg_add -rv.

It seems OK now!


----------



## bernardomaciel (Jun 12, 2010)

Thanks for your help!

Bernardo


----------

