Mac OS M1 Monterey 12.4: wrong python library with "Port" - python

I´ve got a new MacBook Pro with M1 chip and it seems as if not alle of the open source software is converted to arm64.
Nethertheless, I try to compile missing tools (like numpy) manuell from source, like in the good ole days. As I try to do it I have to install, deinstall a lot and one tool is "port" which is working except for one thing that it complains all the time about Libraries I don't use anymore (because some tools (like Eclipse) for example are not working with Python 3.10). Therefore I regressed to Python 3.9 but every time I want to install something with "port" (which it does), it complains about the "old" Python 3.10 libs. How could I get rid of this messages?
Warning: Error parsing file
/opt/local/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/lxml/html/diff.cpython-310-darwin.so: Error opening or reading file

I was in a sort of "Dead-Lock" because versions, Libraries and executables were not consistent with Python, Eclipse, Python pip packages etc, because some packages weren't ported to amd64 until now. For example numpy and I tried to compile it from source which was possible but still not working.
Then I stumbled over a hint in a different problematic were Rosetta was recommended for that specific problem. (I´ve never worked with Rosetta because most applications were running)
So I duplicated the "terminal" Application and configured one for Rosetta, started and installed Python 3.10 in it with all new packages and startet all executables from that terminal.
After some fiddling Eclipse startet with Python and the packages which my application needed, like numpy.
(And in addition to that, it seems as if it very much faster than before)

Related

Embedded python not running on Windows laptop

I am trying to run an embedded python application which runs well on desktop computers but on a laptop it is giving errors.
Initial error was:
The program can't start because api-ms-win-core-timezone-l1-1-0.dll is
missing from your computer.
On installing above, it gives error that api-ms-win-core-file-l2-1-0.dll is missing.
How far this will go? What is the problem and how can this be solved? Thanks for your help.
The problem is that the developers have used some version of C++ to create their programs and the programs require some runtime files (Dynamic Linked Libraries) to be present in order to install/run and the developers do not include those files with their installation (why not?) and the websites for the programs often do not list the prerequisites and requirements of what you need to have installed for their programs to work.
Read more here:
https://answers.microsoft.com/en-us/windows/forum/windows_7-performance/missing-api-ms-win-core-timezone-i1-1-0dll/3754703c-241c-451a-a9b6-e690399fc83e
Try installing the missing files.
https://www.microsoft.com/en-us/download/details.aspx?id=48145
https://support.microsoft.com/en-us/help/2999226/update-for-universal-c-runtime-in-windows

How to create executable file on mac from python script developed on windows

I admit at the beginning that I am a novice python developer, so I apologize in advance for questions that may seem stupid.
I prepared python script with GUI (Tkinter), which use plenty external libraries. I'm working on Windows. Currently, I share my program in the form of an .exe file for Windows users, who do not have Python installed on their PCs. Everything works.
Recently I received a query if I can compile my code on an executable file that is usable for Mac users.
I have a number of questions related to this:
1) can I do it from a PC with Windows or i need Mac? I guess I have to have access to a Mac.
2) will my code work on mac without any editing? What about external libraries? Do you know any easy way to copy/paste my "python with used libraries" from Windows to Mac?
3) will I create a executable file in the same way as Windows, I mean I will use a "Pyinstaller" type library?
Thank you in advance for your help.
1) can I do it from a PC with Windows or i need Mac? I guess I have to have access to a Mac.
You can use a virtual machine and build for mac.
2) will my code work on mac without any editing? What about external libraries? Do you know any easy way to copy/paste my "python with used libraries" from Windows to Mac?
Some libraries have different behavior between macOS and Windows, yes. You should consult the documentation for the libraries you are using.
3) will I create a executable file in the same way as Windows, I mean I will use a "Pyinstaller" type library?
If you're actually using pyinstaller then it is compatible with both mac and windows. You have to check that the library you're using is compatible with both by looking at their docs.
An example of this is to use virtualbox mac image.
Install virtualbox (see this)
Install MacOS (see this)
Install the correct python (obviously python.org)
git clone your repository
Setup your virtual environment (or just pip install -r requirements.txt with your requirements file but I'm a stickler about venvs)
Note: I know you said pyinstaller-like but pyinstaller has a note about macos.
Build!
You shouldn't have any trouble. Just make sure the version of python is the same, as I believe the default on mac is 2.7.
Also, python scripts aren't compiled, rather interpreted, so making the file executable doesn't really mean it's a binary file in this case. I'm not sure what method you used to run python on a computer that doesn't have python on it, as there are a few, but if you can manage to do that on windows, it should work on mac.

Completely remove Python from Yosemite machine

I'm having issues with Python on my 2013 MacBook Air. It seems to be mostly related to pathing, looking for libs in the wrong location based on where the calling lib was installed. I'd like to remove Python from my system and start fresh.
The specific reason I'm asking is due to a virtualenv problem. I created an env with the no-site-packages flag, but when I start my app with foreman, I get an error telling me that Flask isn't available yet when I open a python shell and "import flask", it works fine.
I don't really care which version of Python, or where it's installed as long as everything is consistent. Could I get advisement on how to proceed?
To be clear, I don't think this is a Yosemite issue, just mentioning it as a potential variable.

Modules between multiple versions of Python Linux

I have Python2.6.5 and Python2.4.4 on my linux machine.
At the moment, all the modules I have (wx, ply, pyserial, twisted, to name a few) are installed for the 2.6 version of python. If I try to import wx on Python2.4, I get the expected no module error.
The problem here, is that I have a lot of devices (Let's say over a thousand) all running 2.4.4, which will soon need to be supported by this machine (For builds of code, releases etc). Until now, I've been using an EeePC (Same device as the ones I'm supporting) to do builds and releases, which has worked well. (I develop on the 2.6 machine, and build on the EeePC).
How would I go about getting these modules to work for Python2.4? I've tried reinstalling (With 2.4 as my primary), but that just caused errors. The blogs/answers I've found say to use easy_install, but that doesn't support the packages I need (Or at least, it just died when I tried).
In short: I'm currently using python 2,6, but I'd like it to change to 2.4 for all the modules as that's what I'm going to be using.
You can't share modules between different versions of Python. If you want to use wxPython from Python 2.4, you need to install it for Python 2.4.
You said you tried to install it with Python 2.4 as your "primary". I'm not sure what that means. You would install wxPython for Python 2.4 by running the installer with Python 2.4, like so:
$sudo /usr/bin/python2.4 setup.py install
Or similar.
You can use easy_install as well, but then you need to install Distribute for Python 2.4 first. Did you do that?
I recently wrote a full explanation on my blog about this: http://regebro.wordpress.com/2011/02/02/newbie-hint-on-installing-python-and-its-modules-and-packages/
Don't attempt to share them; this has some chance of success with pure Python modules, but C modules will fail to work. Instead, install them using the appropriate interpreter executable, e.g. python2.4 setup.py install.

Distributing Programs Written in Python [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Distributing Python programs
I have several source codes for some GUI programs I made in Python. I'd like to distribute them. However, I'd like to make it as easy as possible for the end user to get the program up and running. What are the common way's of going about this problem?
This is in reference to Windows XP and on.
All noteworthy linux distributions and Mac OS come shipped with some version of Python. Windows don't have Python installed by default, so you must install it separately in order to run a Python module. Of course the installed Python version must be the same as your program (version 2 or 3).
The easiest way to distribute your program is to just distribute the source code (e.g. send your module by email or upload it somewhere) but in that case, the target PC must have Python installed and meet the dependencies. An even better solution (at least for the community) is to upload your program as a package on PyPi. More info for that procedure can be found HERE.
In some cases there are reasons that prevent you from using these options. For example you can't install python and/or the dependencies (no root/admin account). If that is the case, you can bundle your module(s) along with everything else that is required to run your program (e.g python*.dll on windows). As far as i know the basic options for this kind of distribution are the following ones:
PyInstaller
briefcase
fbs
PyOxidizer
nuitka --standalone
py2app (only for Mac OS)
cx_Freeze
freeze
py2exe
cython --embed
Another approach would be to use Portable Python or in case of Linux/BSD StaticPython
Note : Not all of the aforementioned tools run on all platforms or/and support Python3. Check their documentation.
Unmaintained ones
bbFreeze
esky (unmaintained)
vendorID
gui2exe
You want py2exe, which is an extension of the distutils package.
http://www.py2exe.org/

Categories

Resources