Showing posts with label Python. Show all posts
Showing posts with label Python. Show all posts

Saturday, January 9, 2021

Install pip on Python3

https://stackoverflow.com/questions/31273157/how-to-install-pip-on-compiled-from-source-python

Custom build Python might not come with pip, so you can rebuilt with the following options:

./configure --with-openssl=/usr/local/opt/openssl --with-ensurepip=install

pip need Python ssl module, which in turn need openssl.

Or,  python get-pip.py will also install pip. again, assuming Python is build with ssl module.
Download get-pip.py via:
curl -sSL https://bootstrap.pypa.io/get-pip.py -o get-pip.py

The ensurepip package provides support for bootstrapping the pip installer into an existing Python installation or virtual environment. This bootstrapping approach reflects the fact that pip is an independent project with its own release cycle, and the latest available stable version is bundled with maintenance and feature releases of the CPython reference interpreter.

In most cases, end users of Python shouldn’t need to invoke this module directly (as pip should be bootstrapped by default), but it may be needed if installing pip was skipped when installing Python (or when creating a virtual environment) or after explicitly uninstalling pip.
python -m ensurepip

This invocation will install pip if it is not already installed, but otherwise does nothing. To ensure the installed version of pip is at least as recent as the one available in ensurepip, pass the --upgrade option:

python -m ensurepip --upgrade

By default, pip is installed into the current virtual environment (if one is active) or into the system site packages (if there is no active virtual environment).

Setting up GDB for Debugging Python 3.9.1 on OS X Mojave

https://unconj.ca/blog/setting-up-gdb-for-debugging-python-on-os-x.html

brew install gdb and codesign gdb (updated procedure from: https://sourceware.org/gdb/wiki/PermissionsDarwin)

Brew installed python3 is already in thin format, no need to use lipo to extract, although you can still use lipo to check python executable format. (Non-fat file: python3 is architecture: x86_64)

Providing python3 interpreter (not symbolic link) with path if necessary, after gdb , and this will solve error message like: "0x7ffeefbff800s": not in executable format: file format not recognized

Had to compile Python3 from source to get rid of the following warning: ( ./configure --with-pydebug). Uncommenting SSL related lines in Modules/Setup file is to load ssl module in Python

Reading symbols from python...
(No debugging symbols found in python)

Also build gdb from source code again (./configure --with-python=/usr/local/bin/python3 --disable-werror), as brew info gdb failed with Brew installed python@3.9. Codesign command again for gdb.







Python gdp support: https://devguide.python.org/gdb/

 ~/.gdbinit with content below:

set startup-with-shell off

add-auto-load-safe-path /usr/local/bin