I was trying to run psutil.net_connections() on my OS X (12.1) Macbook Pro in python, but was greeted with the error of syscall failed. This is weird because most of ther other functions of psutil worked fine with no issues, yet somehow net_connections seemed to be the only one not working.
Python 3.8.9 (default, Oct 26 2021, 07:25:53)
[Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import psutil
>>> psutil.net_connections(kind='tcp')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/mastermi/Library/Python/3.8/lib/python/site-packages/psutil/__init__.py", line 2161, in net_connections
return _psplatform.net_connections(kind)
File "/Users/mastermi/Library/Python/3.8/lib/python/site-packages/psutil/_psosx.py", line 248, in net_connections
cons = Process(pid).connections(kind)
File "/Users/mastermi/Library/Python/3.8/lib/python/site-packages/psutil/_psosx.py", line 343, in wrapper
return fun(self, *args, **kwargs)
File "/Users/mastermi/Library/Python/3.8/lib/python/site-packages/psutil/_psosx.py", line 500, in connections
rawlist = cext.proc_connections(self.pid, families, types)
RuntimeError: proc_pidinfo(PROC_PIDLISTFDS) 2/2 syscall failed
If anyone know how to fix this issue it would be greatly appreciated.
P.S. My psutil is version 5.9.0 if that helps
Short answer:
Yes, it is unavailable.
Long answer:
The most likely reason this isn't working on macOS is because it doesn't have a proc filesystem. It isn't much of a bug as it is a lacking feature. As an alternative, you could try sysctl which does have some of the features as proc, but I'm not sure if it fits your use case.
Related
I'm trying to experiment with MLlib on windows with python. So it seems I need SPARK which in turn needs HADOOP. I've installed Anaconda2 which contains python 2.7, numpy, etc.
I've been following this recipe which seems to me mostly getting me where I need to go, but I think I'm stuck on this last error:
Python 2.7.13 |Anaconda 4.3.1 (64-bit)| (default, Dec 19 2016, 13:29:36) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
Setting default log level to "WARN".
To adjust logging level use sc.setLogLevel(newLevel). For SparkR, use setLogLevel(newLevel).
Traceback (most recent call last):
File "C:\spark\bin\..\python\pyspark\shell.py", line 43, in <module>
spark = SparkSession.builder\
File "C:\spark\python\pyspark\sql\session.py", line 179, in getOrCreate
session._jsparkSession.sessionState().conf().setConfString(key, value)
File "C:\spark\python\lib\py4j-0.10.4-src.zip\py4j\java_gateway.py", line 1133, in __call__
File "C:\spark\python\pyspark\sql\utils.py", line 79, in deco
raise IllegalArgumentException(s.split(': ', 1)[1], stackTrace)
pyspark.sql.utils.IllegalArgumentException: u"Error while instantiating 'org.apache.spark.sql.hive.HiveSessionState':"
From this output it is clear to see that there is not error regarding winutils.exe not being found.
Also, the exception is originating in the java domain of py4j, but we've lost the back-trace thanks to the IllegalArgumentException.
All guidance appreciated!
Cheers
Intel Data Analytics Acceleration Library (Intel DAAL) has been installed successfully on my ubuntu. However, when running examples located at compilers_and_libraries_2017/linux/daal/examples/python/source/distance, I got following error. Anybody have this problem before?
$ source activate intelpython
(intelpython) W2600CR:/compilers_and_libraries_2017/linux/daal/examples/python/source/distance$
$ python3.5
Python 3.5.2 |Intel Corporation| (default, Feb 5 2017, 09:07:18)
[GCC 4.8.2 20140120 (Red Hat 4.8.2-15)] on linux
Type "help", "copyright", "credits" or "license" for more information.
Intel(R) Distribution for Python is brought to you by Intel Corporation.
Please check out: https://software.intel.com/en-us/python-distribution
>>>
(intelpython)$ :/compilers_and_libraries_2017/linux/daal/examples/python/source/distance$ python3.5 cos*.py
Traceback (most recent call last):
File "cos_dist_dense_batch.py", line 48, in <module>
DataSourceIface.doDictionaryFromContext
File "/media/liqisuccess/76F07852F0781A97/Ubuntu/App/Anaconda3/envs/intelpython/lib/python3.5/site-packages/daal/data_management/__init__.py", line 4540, in __new__
return FileDataSource_CSVFeatureManagerFloat64(*args)
File "/media/liqisuccess/76F07852F0781A97/Ubuntu/App/Anaconda3/envs/intelpython/lib/python3.5/site-packages/daal/data_management/__init__.py", line 3534, in __init__
this = _data_management.new_FileDataSource_CSVFeatureManagerFloat64(*args)
SystemError: Error on file open
I ran into the same problem. After I dig into the sample source, I found that it's due to the csv file path.
Just cd to compilers_and_libraries_2017/linux/daal/examples/python and run the sample again.
I am working on windows box with 8 processors. I have to run a python script that does mass data processing. When run as such, the script uses only one processor. I learnt that, to harness the power of multiple processors, I can use parallel python (pp) library.
I installed the library on my machine and followed the instructions available at http://www.parallelpython.com/content/view/15/30/#QUICKSMP
However, the code to configure pp fails on my machine:
Python 2.7.1 (r271:86832, Nov 27 2010, 17:19:03) [MSC v.1500 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import pp
>>> job_server = pp.Server()
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
job_server = pp.Server()
File "C:\Python27\lib\site-packages\pp.py", line 343, in __init__
self.set_ncpus(ncpus)
File "C:\Python27\lib\site-packages\pp.py", line 503, in set_ncpus
range(ncpus - len(self.__workers))])
File "C:\Python27\lib\site-packages\pp.py", line 148, in __init__
self.start()
File "C:\Python27\lib\site-packages\pp.py", line 161, in start
self.pid = int(self.t.receive())
File "C:\Python27\lib\site-packages\pptransport.py", line 134, in receive
msg_len = struct.unpack("!Q", size_packed)[0]
error: unpack requires a string argument of length 8
>>>
Can you please tell me how do I get this resolved? I have installed pp version 1.6.0
I have an application in Python 2.5 that listens to a beanstalk queue. It works fine on all machines I tested so far, except from my newly acquired MacBook Pro.
On that computer, when I try to run it I get this error:
Traceback (most recent call last):
File "jobs.py", line 181, in <module>
Jobs().start()
File "jobs.py", line 154, in start
self.jobQueue = Queue()
File "src/utils/queue.py", line 16, in __init__
self.connection = serverconn.ServerConn(self.server, self.port)
File "src/beanstalk/serverconn.py", line 25, in __init__
self.poller = select.poll()
AttributeError: 'module' object has no attribute 'poll'
The serverconn.py has the following imports:
import socket, select
And when I try to run it from command line, it fails as well:
Python 2.5.1 (r251:54863, Jul 23 2008, 11:00:16)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import select
>>> select.poll()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'poll'
Do you have any idea on what can be happening?
PS: Even though I am pretty confident it's not a source problem, if you need some background on the source that's failing, it's available at [http://pastie.org/399342](this pastie).
Updated: since the first answer I got speculates whether select.poll() is or not supported on Mac OS, but I have an iMac too and with the exact same OS version and it works fine:
2009-02-25 00:27:10,067 - Queue - DEBUG - Connecting to BeansTalk daemon # localhost:11300
According to this macports ticket Apple's implementation of poll() is straight up broken. Apple worked around this by disabling poll() in Python and macports now disables poll in their Pythons as well. I think this means you need to look into Python's select.kevent() instead of poll on mac.
I think your answer is here
http://atomized.org/2008/12/python-on-os-x-leopard-lacks-selectpoll/
use the MacPorts version of python on your MBP.
Mac OS X supports this. Apple stock Leopard python 2.5.1 does not.
you will want to download and install MacPorts if you have not already. FYI, I find Porticus to be an excellent GUI around MacPorts.
here is a comparison of stock Leopard python vs. latest MacPorts python2.5...
Leopard python from Apple (python 2.5.1) - select.poll() broken
$ /usr/bin/python
Python 2.5.1 (r251:54863, Jan 13 2009, 10:26:13)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket, select
>>> select.poll()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'poll'
>>>
Macports (python 2.5.4) - select.poll() works!
$ /opt/local/bin/python2.5
Python 2.5.4 (r254:67916, Feb 3 2009, 21:40:31)
[GCC 4.0.1 (Apple Inc. build 5488)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket, select
>>> select.poll()
<select.poll object at 0x11128>
>>>
select.poll()
(Not supported by all operating systems.) Returns a polling object, which supports registering and unregistering file descriptors, and then polling them for I/O events; see section Polling Objects below for the methods supported by polling objects.
My guess is that it's not supported on the macOS.
I'm trying to build PIL 1.1.6 against cygwin or mingw whilst running against a windows install of python. When I do either the build works but I get the following failure when trying to save files.
$ python25
Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from PIL.Image import open
>>> im = open('test.gif')
>>> im.save('output1.gif')
Traceback (most recent call last):
File "", line 1, in
File "c:\Python25\Lib\site-packages\PIL\Image.py", line 1405, in save
save_handler(self, fp, filename)
File "c:\Python25\Lib\site-packages\PIL\GifImagePlugin.py", line 291, in _save
ImageFile._save(imOut, fp, [("gif", (0,0)+im.size, 0, rawmode)])
File "c:\Python25\Lib\site-packages\PIL\ImageFile.py", line 491, in _save
s = e.encode_to_file(fh, bufsize)
IOError: [Errno 0] Error
>>>
I'm not compiling with the libraries for jpeg or zip support but I don't think this should be relevant here.
The failing line seems to be a write in encode_to_file in encode.c.
I'm suspiscious that this occurs because a file descriptor is being passed from Python (which was build under visual studio 2003) to _imaging.pyd but that the file descriptors don't match because on windows file descriptors are and abstraction on top of the operating system. Does anyone know anything about this?
As far as I can tell from some cursory Google searching, you need to rebase the DLLs after building PIL in order for it to work properly on Cygwin.
References:
http://jetfar.com/cygwin-install-python-imaging-library/
http://www.cygwin.com/ml/cygwin/2003-06/msg01121.html