Jython: where is itertools? - python-import

In Jython 2.5.3, trying to import itertools:
>>> from itertools import product
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name product
Yet if you see this page from Jython docs itertools looks a core part of Jython since 2.3.
What do I need on the syspath to import iterools?

itertools.product is not available in Jython 2.5. The function was added in CPython 2.6, and is available in Jython 2.7.
See also https://wiki.python.org/jython/JythonFaq/GeneralInfo#Is_Jython_the_same_language_as_Python.3F.

Related

Python test fails printing dependency on local package

I thought that bazel runs tests in sandbox, but recently I got an error pointing to a local module /usr/lib/python3/dist-packages/OpenSSL/SSL.py. It it correct? How to make bazel run in a sandbox?
exec ${PAGER:-/usr/bin/less} "$0" || exit 1
Executing tests from //master:master_impl_test
-----------------------------------------------------------------------------
Traceback (most recent call last):
File "/home/agent/.cache/bazel/_bazel_agent/374e3bc824f25540df2be790dbb8f41e/sandbox/linux-sandbox/1/execroot/__main__/bazel-out/k8-fastbuild/bin/master/master_impl_test.runfiles/__main__/master/master_impl_test.py", line 14, in <module>
from master import master_impl
File "/home/agent/.cache/bazel/_bazel_agent/374e3bc824f25540df2be790dbb8f41e/sandbox/linux-sandbox/1/execroot/__main__/bazel-out/k8-fastbuild/bin/master/master_impl_test.runfiles/__main__/master/master_impl.py", line 20, in <module>
from azure.cosmos import cosmos_client
File "/home/agent/.cache/bazel/_bazel_agent/374e3bc824f25540df2be790dbb8f41e/sandbox/linux-sandbox/1/execroot/__main__/bazel-out/k8-fastbuild/bin/master/master_impl_test.runfiles/py_deps/pypi__azure_cosmos/azure/cosmos/cosmos_client.py", line 25, in <module>
import requests
File "/home/agent/.cache/bazel/_bazel_agent/374e3bc824f25540df2be790dbb8f41e/sandbox/linux-sandbox/1/execroot/__main__/bazel-out/k8-fastbuild/bin/master/master_impl_test.runfiles/py_deps/pypi__requests/requests/__init__.py", line 95, in <module>
from urllib3.contrib import pyopenssl
File "/home/agent/.cache/bazel/_bazel_agent/374e3bc824f25540df2be790dbb8f41e/sandbox/linux-sandbox/1/execroot/__main__/bazel-out/k8-fastbuild/bin/master/master_impl_test.runfiles/py_deps/pypi__urllib3/urllib3/contrib/pyopenssl.py", line 46, in <module>
import OpenSSL.SSL
File "/usr/lib/python3/dist-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import crypto, SSL
File "/usr/lib/python3/dist-packages/OpenSSL/SSL.py", line 675, in <module>
_lib.Cryptography_HAS_TLSEXT_HOSTNAME, "SNI not available"
AttributeError: module 'lib' has no attribute 'Cryptography_HAS_TLSEXT_HOSTNAME'
Today my project's CI get this error. I fixed this problem in my project, just upgrading pyOpenSSL library to latest version.
Old requirements-file.txt:
requests
pyOpenSSL==19.0.0
urllib3==1.25.3
New requirements-file.txt:
cffi==1.14.4
cryptography==3.3
pycparser==2.20
pyOpenSSL==20.0.0
six==1.15.0
urllib3==1.25.3

ImportError during python run

Currently I am executing doamusic python codes from
https://github.com/yump/doamusic.git
I am using python 3.7.2. (Python IDLE) on windows.
My directory tree is
F:\doamusic_project\doamusic\music.py
when I run music.py, I am getting the following error
Traceback (most recent call last):
File "F:\doamusic_project\doamusic\music.py", line 31, in
from . import util
File "..\doamusic__init__.py", line 1, in
from doamusic.music import *
File "..\doamusic\music.py", line 32, in
from . import _music
ImportError: cannot import name '_music' from 'doamusic' (..\doamusic__init__.py)
What is the reason for not importing _music ?.
You are trying to do an import from .pyx file. A .pyx file must be compiled unlike a .py file.
Try to do that before the import of _music:
import pyximport
pyximport.install()
More info Cython

Unable to run tune_blockmatcher and image_to_pointcloud programs

I am able to capture images on webcams and calibrate them well using
StereoVision library from erget.
But, while trying for execution of tune_blockmatcher and images_to_pointcloud, i found below errors as StereoBM and StereoSGBM classes are unable to import.
>import cv2
>from stereovision.blockmatchers import StereoBM, StereoSGBM
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\stereovision\blockmatchers.py", line 111,
in <module>
class StereoBM(BlockMatcher):
File "C:\Python27\lib\site-packages\stereovision\blockmatchers.py", line 117,
in StereoBM
"stereo_bm_preset": cv2.STEREO_BM_NARROW_PRESET}
AttributeError: 'module' object has no attribute 'STEREO_BM_NARROW_PRESET'
>`
C:\s\StereoVision-master\stereovision>python tune_blockmatcher.py
Traceback (most recent call last):
File "tune_blockmatcher.py", line 34, in <module>
from stereovision.blockmatchers import StereoBM, StereoSGBM
File "build\bdist.win-amd64\egg\stereovision\blockmatchers.py", line 111, in <
module>
class StereoBM(BlockMatcher):
File "build\bdist.win-amd64\egg\stereovision\blockmatchers.py", line 117, in S
tereoBM
"stereo_bm_preset": cv2.STEREO_BM_NARROW_PRESET}
AttributeError: 'module' object has no attribute 'STEREO_BM_NARROW_PRESET'
OS i am running is Windows7, running OPENCV 3.4.0 and Python2.7, installed stereovision library with 'pip install StereoVision'
Any solution for this issue ?
You are facing this issue because the StereoVision framework provided by Daniel Lee does not work with OpenCV 3.
First of all, uninstall OpenCV 3 from your machine.
Then install OpenCV 2 and retry: your problem will be gone.
Hope this helps

Build fail after updating to Mountain Lion

Traceback (most recent call last): File "./Scripts/version.py", line 6, in <module>
from Foundation import NSMutableDictionary File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/Foundation/__init__.py", line 8, in <module>
import objc as _objc File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/objc/__init__.py", line 30, in <module>
from objc._bridgesupport import * File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/objc/_bridgesupport.py", line 9, in <module>
import pkg_resources File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 698, in <module>
class Environment(object): File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 701, in Environment
def __init__(self, search_path=None, platform=get_supported_platform(), python=PY_MAJOR): File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 96, in get_supported_platform
plat = get_build_platform(); m = macosVersionString.match(plat) File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 222, in get_build_platform
plat = get_platform() File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/util.py", line 98, in get_platform File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/sysconfig.py", line 498, in get_config_vars File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/sysconfig.py", line 407, in _init_posix distutils.errors.DistutilsPlatformError: $MACOSX_DEPLOYMENT_TARGET mismatch: now "10.7" but "10.8" during configure Command /bin/sh failed with exit code 1
I'm using python script for version control to TestFlight. While building I get some error. I don't know anything about python. What's the problem here?
XCode Version: 4.4
OS: Mountain Lion 10.8
MacBook PRO mid2009
This appears to be the key part of the message:
$MACOSX_DEPLOYMENT_TARGET mismatch: now "10.7" but "10.8" during
configure
Whatever toolset you are using was configured under Mountain Lion but is now running under Lion, and yet you claim the opposite.
You don't specify what toolset you are using, but it looks like you are going to have to set it up again under your new O/S.
It's a little wonky, but if you edit your .bash_profile and add:
export MACOSX_DEPLOYMENT_TARGET=10.8
You should be okay. I had this same problem when trying to run post-review.
I found the solution, go into your /System/Library/Frameworks/Python.framework/Versions/2.7/lib/distutils/sysconfig.py
Goto line 408 that says "raise DistutilsPlatformError" and add a '#' to comment out that line of code... This will "unleash the python"
You are basically telling python "don't worry its not 10.7, I know" there could be some crashes as a result but I think otherwise. My very complex python applicaiton now compiles on MacOSX 10.8 with no troubles and it seems to do the job, QA still has to test it though.
I am on MacBookPro 2012 MacOSX 10.8

ImportError when importing from Bio.PDB

I want to use Biopython's PDBParser to download PDB files, but this error appears when I try to import it:
Traceback (most recent call last):File "C:\Python27\TAREA 3 FINAL.PY", line 33, in [HTML] from Bio.PDB import * File "C:\Python27\lib\site-packages\Bio\PDB_init_.py", line 15, in [HTML] from PDBParser import PDBParser File "C:\Python27\lib\site-packages\Bio\PDB\PDBParser.py", line 13, in [HTML] import numpy ImportError: No module named numpy
What's going on here?
Biopython requires the numpy module. You need to install numpy in order to use Biopython. You can find the latest version here.

Resources