How can I tell if my Python Installation is "bundled"? - python

I'm installing a package (cx_Oracle), and the documentation says:
Make sure you are not using the bundled Python. This has restricted
entitlements and will fail to load Oracle client libraries.
I'm wondering: how do I tell if my Python installation (if I did not install it) is "bundled" or not?

Normally in MAC OS python comes along with installation of OS itself that means python package included in OS files also called as bundled python. You can check if the python you are using is bundled or not by
which python
On mac os
you should get output like if it's a bundled python
/usr/bin/python
when you want to get the path of externally installed python by
which python3
The only difference is
When you type
python
in terminal it launches pre-installed or bundled python.
If you type
python3
in terminal it launches externally installed python in this cases what the oracle documentation is recommended

Related

Finding Python3 install location

For my project I'd like to be able to dynamically load and use a Python 3 shared library, if one is installed on the system (any version >=3.2). If more than one Python 3 version is installed, it would be nice to know which one is the default (i.e. the one that gets used whenever user types python3 in the terminal).
On Windows, Python install locations can be discovered via the registry, however, I am uncertain if the same can be done on MacOS and Linux. While python3 executable can typically be found on PATH, there seems to be no general way of locating Python's shared library?
Edit: To clarify, I am looking for libpython3.x.so (or libpython3.x.dylib), not the main python executable.
Also, I'd like the discovery method to be portable: it should work on different Linux distros, and for different package managers on MacOS, so saying e.g. "It's in /usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/Python" doesn't cut it.
In shell on MacOS or Linux, type:
which python and/or
which python3 to get your answer
Example on a VM on my machine (under Docker):
uwsgi#08c2ed391dae:/src/psf$ which python
/usr/bin/python
uwsgi#08c2ed391dae:/src/psf$ which python3
/usr/bin/python3
Have you tried :
'''
>>> import sys
>>> sys.path
'''
That shows lib path.

Import Python packages across Windows and Linux using .pth file

I'm using software that is built for Windows with no version for Linux. They have dedicated Python library called ArcPy, that has scripts of all of the tools available in this software.
On Ubuntu 16.04 I'm trying to import this package to my Python, so I can use all those scripts. Inside /usr/local/lib/python2.7/site-packages I created Desktop.pth into which I echoed:
/media/adam/somedisk/Program\ Files\ \(x86\)/ArcGIS/Desktop10.5/bin
/media/adam/somedisk/Program\ Files\ \(x86\)/ArcGIS/Desktop10.5/arcpy
/media/adam/somedisk/Program\ Files\ \(x86\)/ArcGIS/Desktop10.5/ArcToolBox/Scripts
Now entering Python shell and typing import arcpy returns ImportError: No module named arcpy. I know I typed the paths with correct escaping, because I can cd them.
Is it a correct way of importing Python packages across OSs? What went wrong here?
You can not use arcpy unless, either ArcGIS Server or ArcGIS engine is installed in the machine. ArcPy does not work without the binaries.

Create standalone applications with py2app by not using the system installation of Python on Mac?

I am using py2app to package a Python application to be used on other Mac computers. I am currently running OSX 10.7.5 and the system Python installation on my computer is Python 2.7.1. When I package the program with py2app, it works on my computer, but will not work on another computer - the error that comes up is it cannot locate a Python runtime.
From what I have read about this, it looks like my py2app build is using the system installation of Python on my computer and therefore will only create a semi-standalone application instead of a standalone application.
Also, I have seen that to fix this you need to package it with a separately downloaded Python. I have downloaded a separate Python and even tried to change my PYTHONPATH in my .bash_profile file, but cannot seem to get py2app to build with a different version of Python.
Can anyone point me in the right direction as to how to do this?
I have read other questions and wasn't able to find out how to do it in my case. If there is any other information you need to know to help, please let me know.
py2app builds the application bundle using the running version of python. To use the separate install of python you therefore have to make sure that py2app and the other libraries you use are available in that installation of Python, then use that installation to build the application.
For example:
$ /Library/Frameworks/Python.framework/Versions/2.7/bin/easy_install py2app
$ .../bin/easy_install ...
$ /Library/Frameworks/Python.framework/Versions/2.7/bin/python setup.py py2app
The simplest way of handling this IMO is by utilizing MacPorts. You can download and install a standalone version of Python and just about any other package you might need.
Get macports: https://www.macports.org
sudo port install py27-py2app
sudo port select python python27
Now your standalone Python is the default, and py2app will run and bundle using that version of Python.

Installing rpm module for (non-system) Python

I need to support some software that is using an old Python version (2.4). So I have downloaded and compiled Python 2.4 and installed it in a virtualenv. So far, all OK and normal procedure.
But the software is trying to import an rpm module. And I cannot find a source for that module (it is not part of the standard Python library, afaict).
Typically, once the virtualenv is enabled (source env/bin/activate) I can install required software using easy_install. But easy_install rpm is failing to find anything. There is a pyrpm module, but it is not the same thing (it installs a module called "pyrpm"). And google searches are useless, as they all link to articles on how to build rpms...
If I were using the system python (on Ubuntu) I could install the python-rpm package. But that is for Python 2.7. How do I install the equivalent for Python 2.4?
[My impression is that the rpm libraries, used by many Linux systems, include a Python library, which is packaged as python-dev by the distro. But I can't see how to access that for an arbitrary python version.]
I AM NOT LOOKING FOR AN RPM THAT CONTAINS PYTHON 2.4. I AM LOOKING FOR A MODULE NAMED rpm THAT IS USED BY SOFTWARE WRITTEN FOR PYTHON 2.4.
It's right there, in the python-rpm RPM package:
http://rpmfind.net/linux/rpm2html/search.php?query=python-rpm
You will probably want to download the package contents, extract them, and then use
python setup.py install
From your active environment.
Of course, as it's pre compiled, you might have trouble getting the C extension to run.
I'm not familiar enough with RPM's to know whether you can get the source from there.
No guarantees the package will work with your python version though.
there's no simple way to do this; the python library is part of the system rpm package and interfaces to C code, so is closely tied to the rpm package installed on your machine.
instead, it's much simpler to install an old OS in a VM (eg CentOS 5) that uses Python 2.4. then everything is consistent and works.
the sources for the rpm module can be found here: http://www.rpm.org/wiki/Download
After you download the wanted version read and follow the INSTALL instructions in order to compile it on your target OS. Afterwards make sure you add the correct path to the 'site-packages' folder the installation chose into your PYTHONPATH environment variable.
To test start your python interpreter and run 'import rpm'
HTH,
Ran

I am installing python 3 on snow leopard, what am I installing exactly?

I'm having difficulty installing python 3 on snow leopard.
I'm having difficulty because I have no idea what I am installing. (I do understand that python is a language, and that it uses a virtual machine)
Where can I get an overview of all the parts that make up working installation of python and how they need to be configured?
I want to understand this so that I can use python 3, but not break the other installations on my system.
There is normally no need to build Python on Mac OS X from source. If you want the most recent Python 3, download and install one of the two official Python 3.2 installers for OS X from python.org here. The Python installers from python.org install a framework build of Python 3 rooted at
/Library/Frameworks/Python.framework/Versions/3.2
In that directory, you will find bin, lib, and other directories unique to that version. If you install another Python versions (say, 2.7) using python.org installers, it will be be installed under /Library/Frameworks/Python.framework/Versions/2.7, completely independent of the 3.2 version. There will also be a version of IDLE.app and other files installed into /Applications/Python m.n (3.2, 2.7, etc.). The Apple-supplied system Pythons (2.6.1 and 2.5.4 for OS X 10.6) are installed in:
/System/Library/Frameworks/Python.framework/Versions/
again a completely separate location. Thus, the system Python files do not need to be and should not be altered or removed. The python.org installers have the option to alter your shell PATH variable to prepend the appropriate framework bin directory to your path so that the newly installed Python will be found first. With Python 3 there is no conflict anyway, since you need to invoke it by python3, rather than python.
The python.org installers also have the option to install symlinks from /usr/local/bin to the important files in the framework bin directory but, for various reasons, those are not particularly useful. In general, you need to include the framework bin directory in your execution PATH; with that, the /usr/local/bin symlinks are usually not needed.
If you are really interested in the details, download the source tarball and examine configure.in and the top level makefile. The script that is used to build the installer is in Mac/BuildInstaller.
For additional information about Python on Mac OS X and the use of Tkinter, IDLE, and Tcl/Tk, see this page.
Go to Python.org
Download the source
Unpack
Follow the steps in the README (see below)
It will install to python3 by default thereby not breaking your other distros.
On Unix, Linux, BSD, OSX, and Cygwin:
./configure
make
make test
sudo make install
This will install Python as python3.
You can pass many options to the configure script; run "./configure --help" to
find out more. On OSX and Cygwin, the executable is called python.exe;
elsewhere it's just python.
On Mac OS X, if you have configured Python with --enable-framework, you should
use "make frameworkinstall" to do the installation. Note that this installs the
Python executable in a place that is not normally on your PATH, you may want to
set up a symlink in /usr/local/bin.
On Windows, see PCbuild/readme.txt.
If you wish, you can create a subdirectory and invoke configure from there. For
example:
mkdir debug
cd debug
../configure --with-pydebug
make
make test
(This will fail if you also built at the top-level directory. You should do a
"make clean" at the toplevel first.)
--
You are installing packages and modules. You can download the source and look through the directory. Everything installed is as it appears. This is not Windows where files are spewed everywhere on the system.

Categories