0

On a distant server on Rocky8, as I needed recent Python and as I don't have admin privileges to install with sudo, finally I succeeded to build and install Python 3.11 on my local home.

When I invoke python3.11 or run a script all is fine, my issue is with pip install !

This is the tree for Python 3.11 and pip:

Python311/
    bin/
        2to3-3.11
        idle3.11
        pip3.11
        pydoc3.11
        python3.11
        python3.11-config 
    lib/
        python3.11/
            site-packages/
                pip/
                    __init__.py
                    _internal
                    __main__.py
                    __pip-runner__.py
                    __pycache__
                    py.typed
                    _vendor

I didn't yet create any alias or added anything to PYTHONPATH.

If I do:

$HOME/tools/Python311/bin/pip3.11 --version

I got as expected:

pip 22.3.1 from /tr2dev01/tr2/tools/Python311/lib/python3.11/site-packages/pip (python 3.11)

and

$HOME/tools/Python311/bin > ./python3.11 -m ensurepip
Requirement already satisfied: setuptools in /tr2dev01/tr2/tools/python/Python311/lib/python3.11/site-packages (65.5.0)

Requirement already satisfied: pip in /tr2dev01/tr2/tools/python/Python311/lib/python3.11/site-packages (22.3.1)

The issue is when I run:

$HOME/tools/Python311/bin > ./python3.11 -m ./pip3.11 install numpy

got:

/tr2dev01/tr2/tools/Python311/bin/python3.11: Relative module names not supported

Or:

$HOME/tools/Python311 > ./bin/python3.11 -m ./lib/python3.11/site-packages/pip install numpy

got:

/tr2dev01/tr2/tools/Python311/bin/python3.11: Relative module names not supported

Is my directory tree structure good?

What is the correct syntax? What is required for it to work?

sinoroc
  • 18,409
  • 2
  • 39
  • 70
maxashtar
  • 21
  • 5
  • `./python3.11 -m ./pip3.11` is incorrect. It has to be `./python3.11 -m pip`, the `-m pip` part is always the same whatever Python interpreter you use. https://snarky.ca/why-you-should-use-python-m-pip/ – sinoroc Mar 12 '23 at 12:29

1 Answers1

1

Running something like ./python3.11 -m ./pip3.11 is incorrect. What you want to do is ./python3.11 -m pip. The -m pip notation will instruct the Python interpreter to look for site-packages/pip/__main__.py and run it.

Related:

sinoroc
  • 18,409
  • 2
  • 39
  • 70