macOS trusts Python whl files, but not tar files - python

I provide my python c extension as both as a tar file, as well as a whl file.
On macOS, I am surprised that there are no problems installing the wheel for my extension. When setting PYTHONPATH to my python extension in the tarball, I am immediately met with the dialog about unverified developers.
Could someone please explain why macOS trusts my unsigned python extension, but has no problem if I package it in a wheel file.
Update: This is the error I see after I close the dialog box:
>>> import devsim
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/jsanchez/Downloads/devsim_macos_v2.3.7rc1/lib/devsim/__init__.py", line 8, in <module>
from .devsim_py3 import *
ImportError: dlopen(/Users/jsanchez/Downloads/devsim_macos_v2.3.7rc1/lib/devsim/devsim_py3.so, 0x0002): tried: '/Users/jsanchez/Downloads/devsim_macos_v2.3.7rc1/lib/devsim/devsim_py3.so' (code signature in <ED44BB00-36CF-39A8-8999-8309CBA016E4> '/Users/jsanchez/Downloads/devsim_macos_v2.3.7rc1/lib/devsim/devsim_py3.so' not valid for use in process: library load disallowed by system policy)
Could someone please explain why macOS trusts my unsigned python extension, but has no problem if I package it in a wheel file.
Update 2:
From what I can see. If I download the tgz to my Downloads folder using Chrome, I am getting the error. If I download the tgz using curl, it works. I am thinking that Chrome is adding this bad attribute.

Thanks to #GordonDavisson for his tip concerning the attributes. It turns out the issue was related to google chrome. If I download the file from Github using Chrome I get:
com.apple.macl 72
com.apple.metadata:kMDItemWhereFroms 655
com.apple.quarantine 57
and using curl I get no attributes.
I have lax security permissions in Chrome (no safe browsing), but this still occurs. I will be sure to look out for this the next time I encounter it.
Update
I found this very useful post concerning the current macOS landscape:
https://eclecticlight.co/2021/02/18/code-signing-requirements-for-scripts-and-apps-in-big-sur/

Related

python cgal bindings on windows problems

i'm a python noob - so maybe it is something simple - and please be patient ;-)
i'm stuck to get the cgal bindings running:
so i what i did so far:
installed/built cgal 5.1.1 and boost 1.74 using vcpkg
downloaded swig 4.0.2 and made the system path.
then i followed this: https://github.com/CGAL/cgal-swig-bindings/wiki/Installation
as a difference i did the cmake with the gui and then i compiled everything with visual studio.
there were some warnings, but no errors and it generated a folder with many *py, *pyd, *cxx files and a release folder with *lib and *exp files
when i now try test.py from the example folder i get:
C:\Dev\cgal-swig-bindings\examples\python>python test.py
Traceback (most recent call last):
File "test.py", line 2, in
from CGAL import CGAL_Triangulation_3
ModuleNotFoundError: No module named 'CGAL'
which somehow makes sense, as i never told python about the new stuff
so i copied test.py into the folder with the generated files folder with generated files
i get the same message...
i also tried pip install cgal-bindings. but it can't find CGAL (and other stuff...) altough i think i generated the path variable...
any hints on what i do wrong?
how can i get python to find the modules? (i also generated a system variable "PYTHONPATH" pointing at "C:\Dev\cgal-swig-bindings\build\CGAL-5.1.1_release\build-python\CGAL" - no difference)

Error importing opencv, unable to import VideoCapturePlayer

I am trying to work with OpenCV in Python 2.7, however when I simply import cv2, I am getting this error:
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "cv2.py", line 9, in <module>
from VideoCapturePlayer import *
ImportError: No module named VideoCapturePlayer
I figured that VideoCapturePlayer may be in pygame or pycam, but when I import both, no problems arise.
I have searched my folders and the web for VideoCapturePlayer. My folders do not contain it, and the internet provided a .py file, but I do not know where I should put it. Any help is greatly appreciated, thank you.
Edit: I guess I should include that I am on Windows 7 64-bit
The link you provided is for downloading the entire OpenCV project, including all the libraries and bindings for C++, Java, etc. etc. For the Python bindings, it's much easier to visit my favorite module site on the Internet, Christoph Gohlke's Python Extension Packages for Windows repository. Find the OpenCV section, pick AMD64 or Win32, pick py2.7 or py2.6, and wait a bit for the self-extracting archive to download. Run it, hit OK for all the prompts, and you should be all set. Fire up IDLE or run python from the command line, and running import cv2 should give you no response at all - indicating that everything got set up just fine.
Good luck!

Problems using Metakit for Python on Windows

I'm having problems trying to use Metakit for Python on Windows. It always report this error:
Traceback (most recent call last):
File "<pyshell#86>", line 1, in <module>
import metakit
File "C:\Python27\lib\site-packages\metakit.py", line 22, in <module>
from Mk4py import *
ImportError: No module named Mk4py
I've already:
Downloaded metakit.py and Mk4py.dll from http://equi4.com/pub/mk/ (official release)
Copied metatkit.py to C:\Python27\lib\site-packages\
Copied Mk4py.dll to C:\Python27\DLLs\
I have installed Python 2.7.5 win32 version
Any idea to solve this problem?
I also had the same problem and couldn't get the system to work with the provided dlls. I also tried compiling metakit from source to make it work and installing it from an the official source via egg, which failed in the same way (as it compiles from source).
Using my older windows XP machine with visual studio 2002 I managed to build it from source and install it with just a minor change of the setup script (changing every instance of msvc60 to msvc70 in the setup script). However, copying those files to my windows 8 machine still failed, and even copying what appeared to be the changes were unsuccessful.
In the end I copied my entire python directory from the xp machine to the windows 8 machine and now it is working without issues.
Obviously i could provide my dlls but I doubt they would be any more successful than the provided ones.
My next step is to reduce my reliance on having to use metakit as it seems very poorly supported.

python import cx_Oracle error

I'm trying to install cx_Oracle to use Django inspectdb on an existing Oracle database to create models.py automatically. So far i'ts been very hard. I'm running a VM with Fedora 14 64bit and Python 2.7 and followed a mix of pages found with google to get it installed with sudo -E easy_install cx_Oracle
When I fire up python from terminal and try to import cx_Oracle to test the installation I get this:
>>> import cx_Oracle
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: libclntsh.so.11.1: cannot enable executable stack as shared object requires: Permission denied
I've never seen this before and don't know what to do. Any help would be very much appreciated.
Thanks in advance,
Stefano
It was SELinux, Fedora security system that was blocking it and I didn't notice! Installation was ok and it's working now. Sorry and thanks everyone.
It has occurred for me long time back
There are two set of libraries for 32 bit and 64 bit just copy these "*.so" files to the appropriate directories.
Please note there are more than 1 file[around 5 i guess] to be copied . just use a find command to locate your present location of libclntsh.so file and copy it to the respective lib directories. you can find the rest of the files since same exception pops up for everything.
You forgot to add the instantclient path in ldconfig; adding it will fix this problem.

How to Make a PyMe (Python library) Run in Python 2.4 on Windows?

I want to run this library on Python 2.4 in Windows XP.
I installed the pygpgme-0.8.1.win32.exe file but got this:
>>> from pyme import core
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "C:\Python24\Lib\site-packages\pyme\core.py", line 22, in ?
import pygpgme
File "C:\Python24\Lib\site-packages\pyme\pygpgme.py", line 7, in ?
import _pygpgme
ImportError: DLL load failed: The specified module could not be found.
And then this pop up comes up
---------------------------
python.exe - Unable To Locate Component
---------------------------
This application has failed to start because python25.dll was not found. Re-installing the application may fix this problem.
---------------------------
OK
Do I need to "compile" it for Python 2.4? How do I do that?
While the pygpgme project does not clearly document it, it's clear from the error message you got that their .win32.exe was indeed compiled for Python 2.5.
To compile their code for Python 2.4 (assuming they support that release!), download their sources, unpack them, open a command window, cd to the directory you unpacked their sources in, and run python setup.py install. This will probably not work unless you have the right Microsoft C compiler installed (MSVC 6.0 if I recall correctly).
It's no doubt going to be much less trouble to download, install and use Python 2.5 for Windows (it can perfectly well coexist with your current 2.4, no need to remove that). Is that a problem?

Categories