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
Related
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.
I am new to Python so I could perhaps learn the basics first... I'm a musician and keen to learn how to use Python with music.
I installed Python 3.8 x64 for Windows 10. I then used pip to install music21.
Opened the Python Shell, typed import music21 and got this:
Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:37:50) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> import music21
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import music21
File "D:\Python\lib\site-packages\music21\__init__.py", line 170, in <module>
from music21 import base
File "D:\Python\lib\site-packages\music21\base.py", line 94, in <module>
from music21 import common
File "D:\Python\lib\site-packages\music21\common\__init__.py", line 39, in <module>
from music21.common.parallel import *
File "D:\Python\lib\site-packages\music21\common\parallel.py", line 19, in <module>
from music21.ext.joblib import Parallel, delayed # #UnresolvedImport # type: ignore
File "D:\Python\lib\site-packages\music21\ext\joblib\__init__.py", line 119, in <module>
from .parallel import Parallel
File "D:\Python\lib\site-packages\music21\ext\joblib\parallel.py", line 32, in <module>
from .externals.cloudpickle import dumps, loads
File "D:\Python\lib\site-packages\music21\ext\joblib\externals\cloudpickle\__init__.py", line 3, in <module>
from .cloudpickle import *
File "D:\Python\lib\site-packages\music21\ext\joblib\externals\cloudpickle\cloudpickle.py", line 167, in <module>
_cell_set_template_code = _make_cell_set_template_code()
File "D:\Python\lib\site-packages\music21\ext\joblib\externals\cloudpickle\cloudpickle.py", line 148, in _make_cell_set_template_code
return types.CodeType(
TypeError: an integer is required (got type bytes)
I have found example code to run with music21 but I can't use it if I get errors.
Hope someone can help. Apologies if I'm being a complete n00b. Did look at other questions but didn't find or didn't understand the answers.
So from your output, the main piece that seems most useful is the TypeError: an integer is required (got type bytes) in the _make_cell_set_template_code function in the D:\Python\lib\site-packages\music21\ext\joblib\externals\cloudpickle\cloudpickle.py file. This issue could be an issue with music21 not being compatible with Python 3.8. I'm reading the documentation from https://web.mit.edu/music21/ and it says v.5 support Python 3.4-3.6, so I would try to get on one of those versions and restart the process you did to get to the step above. Hope this helps!
music21 v5 does not support Python 3.8 -- choose 3.7 or download the latest Git from github.
EDIT: v5.7.2 now supports 3.8
I am trying to install Anaconda (32-bit) over an existing Python environment (32-bit) on a Windows 7 64-bit system. I am able to get Anaconda python environment running, but the navigator won't respond and conda command fails with an error
ValueError: failed to parse CPython sys.version
I have removed C:\Python27; C:\Python27\Scripts; from PATH variable, but I must be missing something!
C:\Users\gaurav>python
Python 2.7.13 |Anaconda 4.3.0 (32-bit)| (default, Dec 19 2016, 13:36:02) [MSC v.
1500 32 bit (Intel)] 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
>>> quit()
C:\Users\gaurav>conda
An unexpected error has occurred.
Please consider posting the following information to the
conda GitHub issue tracker at:
https://github.com/conda/conda/issues
Traceback (most recent call last):
File "C:\Users\gaurav\Anaconda2\Scripts\conda-script.py", line 5, in <module>
sys.exit(conda.cli.main())
File "C:\Users\gaurav\Anaconda2\lib\site-packages\conda\cli\main.py", line 167
, in main
return conda_exception_handler(_main, *args)
File "C:\Users\gaurav\Anaconda2\lib\site-packages\conda\exceptions.py", line 6
33, in conda_exception_handler
print_unexpected_error_message(e)
File "C:\Users\gaurav\Anaconda2\lib\site-packages\conda\exceptions.py", line 5
60, in print_unexpected_error_message
info_stdout, info_stderr = get_info()
File "C:\Users\gaurav\Anaconda2\lib\site-packages\conda\exceptions.py", line 5
30, in get_info
args.func(args, p)
File "C:\Users\gaurav\Anaconda2\lib\site-packages\conda\cli\main_info.py", lin
e 142, in execute
from conda.api import get_index
File "C:\Users\gaurav\Anaconda2\lib\site-packages\conda\api.py", line 1, in <m
odule>
from .core.index import get_index
File "C:\Users\gaurav\Anaconda2\lib\site-packages\conda\core\index.py", line 2
2, in <module>
from .package_cache import PackageCache
File "C:\Users\gaurav\Anaconda2\lib\site-packages\conda\core\package_cache.py"
, line 9, in <module>
from .path_actions import CacheUrlAction, ExtractPackageAction
File "C:\Users\gaurav\Anaconda2\lib\site-packages\conda\core\path_actions.py",
line 32, in <module>
from ..gateways.download import download
File "C:\Users\gaurav\Anaconda2\lib\site-packages\conda\gateways\download.py",
line 15, in <module>
from ..connection import CondaSession
File "C:\Users\gaurav\Anaconda2\lib\site-packages\conda\connection.py", line 5
5, in <module>
python=platform.python_implementation(),
File "C:\Python27\Lib\platform.py", line 1460, in python_implementation
return _sys_version()[0]
File "C:\Python27\Lib\platform.py", line 1422, in _sys_version
repr(sys_version))
ValueError: failed to parse CPython sys.version: '2.7.13 |Anaconda 4.3.0 (32-bit
)| (default, Dec 19 2016, 13:36:02) [MSC v.1500 32 bit (Intel)]'
C:\Users\gaurav>
I was only updating the system environment variable PATH, and was not touching PythonPath, which was set to C:\Python27. This was the cause for that ValueError. I found my solution in this stackoverflow answer.
I can't seem to get WeasyPrint to work on Windows with Python 3.4 or 3.5. Has anyone been able to do this? There aren't forums at weasyprint.org and the IRC channel is dead.
I've been able to install using both Python 3.4.3 and 3.5.1. I've followed the guideline found here [1]. I've also made note that WeasyPrint's site claims it should work with Python 2.6+ or 3.1+.
When I install for Python 3.4.3 and open the Python shell and simply 'import weasyprint' I get this:
C:\Python34>python
Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import weasyprint
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python34\lib\site-packages\weasyprint\__init__.py", line 337, in <module>
from .html import find_base_url, HTML5_UA_STYLESHEET, get_html_metadata # noqa
File "C:\Python34\lib\site-packages\weasyprint\html.py", line 41, in <module>
HTML5_UA_STYLESHEET = CSS(filename=os.path.join(root, 'css', 'html5_ua.css'))
File "C:\Python34\lib\site-packages\weasyprint\__init__.py", line 224, in __init__
with result as (source_type, source, base_url, protocol_encoding):
File "C:\Python34\lib\contextlib.py", line 59, in __enter__
return next(self.gen)
File "C:\Python34\lib\site-packages\weasyprint\__init__.py", line 294, in _select_source
base_url = path2url(filename)
File "C:\Python34\lib\site-packages\weasyprint\urls.py", line 87, in path2url
path = pathname2url(path)
File "C:\Python34\lib\nturl2path.py", line 46, in pathname2url
if not ':' in p:
TypeError: 'str' does not support the buffer interface
>>>
I get a similar traceback when importing in Python 3.5.1, with the exception of the final TypeError being:
TypeError: a bytes-like object is required, not 'str'
[1] https://gist.github.com/doobeh/3188318
I had looked through the issues list at weasyprint.org and didn't find anyone else complaining about Python 3.x compatibility with WeasyPrint. Then I happened upon a pull request that did complain about just that and mirrors my difficulties exactly. So off the shelf it does not work with Python 3.x, but with a small hack it does, see [1]. I'll add some comments to the pull request and hopefully this incompatibility will get looked at.
[1] https://github.com/Kozea/WeasyPrint/pull/132
I want to install paramiko on win 7 32bit ,the python is 3.3 .
I can compile it,but get follow errors:
Installed c:\python33\lib\site-packages\paramiko-1.8.0-py3.3.egg
Processing dependencies for paramiko==1.8.0
Searching for pycrypto==2.6
Best match: pycrypto 2.6
Adding pycrypto 2.6 to easy-install.pth file
Using c:\python33\lib\site-packages
Finished processing dependencies for paramiko==1.8.0
C:\Users\MC\Downloads\paramiko-paramiko-v1.8.0-9-g786920a>python
Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:55:48) [MSC v.1600 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import paramiko
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File ".\paramiko\__init__.py", line 62, in <module>
from .transport import SecurityOptions, Transport
File ".\paramiko\transport.py", line 68, in <module>
class SecurityOptions (object):
ValueError: 'ciphers' in __slots__ conflicts with class variable
>>>
Paramiko does not run on Python 3. Yet. I'm working on a development branch (https://github.com/dorianpula/paramiko/tree/python3-support) to add support for Python 3, and I'm working on fixing this particular issue.