AIX Open Source

AIX Open Source

Share your experiences and connect with fellow developers to discover how to build and manage open source software for the AIX operating system

 View Only
  • 1.  Python3 PIP error

    Posted Tue December 07, 2021 02:06 PM

    I am new to open source packaging on AIX.  Some background, server is at AIX 7100-05-04, with YUM configured to manage RPM packages.

    I have installed some python modules in the past, without much issue, but am using this - Installing and configuring Python machine learning packages on IBM AIX – IBM Developer -  to add Pandas.  I've encountered a number of issues after installing the requisite RPM packages.  After a fair amount of research, I determined the libiconv RPM was backlevel.  Once updated, I stopped seeing the errors that was causing NumPy to fail. 

    Now, I appear to have run into this:

    root@akxferp2:/opt/freeware/bin> python3 -m pip install numpy
    Traceback (most recent call last):
    File "/opt/freeware/lib64/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
    File "/opt/freeware/lib64/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
    File "/opt/freeware/lib/python3.7/site-packages/pip/__main__.py", line 23, in <module>
    from pip._internal.cli.main import main as _main # isort:skip # noqa
    File "/opt/freeware/lib/python3.7/site-packages/pip/_internal/cli/main.py", line 10, in <module>
    from pip._internal.cli.autocompletion import autocomplete
    File "/opt/freeware/lib/python3.7/site-packages/pip/_internal/cli/autocompletion.py", line 9, in <module>
    from pip._internal.cli.main_parser import create_main_parser
    File "/opt/freeware/lib/python3.7/site-packages/pip/_internal/cli/main_parser.py", line 7, in <module>
    from pip._internal.cli import cmdoptions
    File "/opt/freeware/lib/python3.7/site-packages/pip/_internal/cli/cmdoptions.py", line 24, in <module>
    from pip._internal.cli.progress_bars import BAR_TYPES
    File "/opt/freeware/lib/python3.7/site-packages/pip/_internal/cli/progress_bars.py", line 12, in <module>
    from pip._internal.utils.logging import get_indentation
    File "/opt/freeware/lib/python3.7/site-packages/pip/_internal/utils/logging.py", line 18, in <module>
    from pip._internal.utils.misc import ensure_dir
    File "/opt/freeware/lib/python3.7/site-packages/pip/_internal/utils/misc.py", line 31, in <module>
    from pip._internal.locations import (
    File "/opt/freeware/lib/python3.7/site-packages/pip/_internal/locations/__init__.py", line 9, in <module>
    from pip._internal.models.scheme import SCHEME_KEYS, Scheme
    ImportError: cannot import name 'SCHEME_KEYS' from 'pip._internal.models.scheme' (/opt/freeware/lib/python3.7/site-packages/pip/_internal/models/scheme.py)

    I have come across a couple recommendations to create a "virtual environent" for this install. I am hoping someone can confirm this is the solution to the above.  In addition,  I am unfamiliar with what it means to create a virtual environment for python, accessibility, etc... If anyone is able to point me to useful documentation on the subject, I'd be grateful.  

    Thanks
    Tom




    ------------------------------
    Thomas Crucian
    ------------------------------



  • 2.  RE: Python3 PIP error

    Posted Wed December 08, 2021 02:44 AM

    Looks like pip is updated manually and then python3 rpm is updated. 
    Pip & setuptools bundled with python3 main rpm may not be the latest most of the time since pip & setuptools are updated frequently. 
    So in this case, it is out of sync. You can remove the locations directory "/opt/freeware/lib/python3.7/site-packages/pip/_internal/locations" and try again.

    In the future , we are planning to provide pip & setuptools as a separate rpm which will avoid these kind of problems.



    ------------------------------
    Ayappan P
    ------------------------------



  • 3.  RE: Python3 PIP error

    Posted Wed December 08, 2021 02:52 AM

    The more clean way to fix the problem is to remove the pip & setuptools in "/opt/freeware/lib/python3.7/site-packages" and invoke ensurepip which will install the python3 bundled pip & setuptools.  

    rm -rf /opt/freeware/lib/python3.7/site-packages/pip*
    rm -rf /opt/freeware/lib/python3.7/site-packages/setuptools*

    python3 -m ensurepip 



    ------------------------------
    Ayappan P
    ------------------------------



  • 4.  RE: Python3 PIP error

    Posted Wed December 08, 2021 09:48 AM
    Thanks for the help.  I had a suspicion I had caused this issue and had attempted an over-write install of Python3 which had no impact.  After continuing to troubleshoot, I was more convinced I'd created a problem with pip.  However, I took a hammer approach, uninstalling Python3 and deleting the folder from /opt/freeware/bin/.  I re-installed python3, updated pip, and that resolved my issue.  

    I will make note of your solution but hopefully I avoid the self-inflicted conflict in the future.

    ------------------------------
    Thomas Crucian
    ------------------------------