General Discussion & Announcements

 View Only
  • 1.  pip directing installs in /tmp rather than it's own directory

    Posted 02-10-2024 23:37

    Hi,

    I am facing problem with python where it is using /tmp to install pip modules and libraries instead of it's own directory site-packages.

    1. I want python to re-direct to /shrd/python and not to /tmp

    # python3 -m pip install --upgrade virtualenv                                                                                       

    WARNING: The directory '/SYSTEM/tmp/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled

    ERROR: Could not install packages due to an OSError: [Errno 133] EDC5133I No space left on device.       

    2. Getting this error while creating environment variable

    # python3 -m venv my_div                                                                                                           

    Error: Command '['/SYSTEM/tmp/my_div/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status

    Can someone help me here with a solution or command through which I can change the installation directory of python?

    Thanks,

    Divyanshu.



    ------------------------------
    Divyanshu Singh
    MVS system programmer
    BMC Software
    Kanpur IN
    ------------------------------


  • 2.  RE: pip directing installs in /tmp rather than it's own directory

    ROCKETEER
    Posted 02-12-2024 13:52

    Hello Divyanshu,

    It's hard to say the exact reason of the issues without additional details. I can only guess.

    1. It seems that you run the command "python3 -m pip install --upgrade virtualenv" by the user who doesn't have home directory, maybe it is "root" user. So pip is trying to create cache folder in "/tmp" folder instead of the user's home folder by default. But by some reason "/tmp" folder is not writeable for that user, that is why we see the first warning. But that is not critical, just pip cache is not used in your case. As for the error "No space left on device" - it looks like there is either no space left on the file system where python is installed ("/shrd/python") or that file system is mounted in read only mode. You can check install location for the packages using the command "python3 -m pip list -v". Anyway packages should be installed by default into the "/shrd/python" folder, not into the "/tmp" folder. But the install location can be changed if you use "user scheme" for installation: https://pip.pypa.io/en/stable/user_guide/#user-installs.

    2. Maybe the same issue as in the previous step - by some reason "/tmp" folder is not writeable for that user. No other ideas at the moment.

    I think you will be able to avoid some or all issues if you will try to install packages by the user who has its own home directory. Or you just need to change default install location as I mentioned above. And it's not good idea to create virtual environment in "/tmp" folder - that folder can be cleared by the OS at some moment and you will loose all your virtual environments.



    ------------------------------
    Vladimir Kudriakov
    Software Engineer
    Rocket Software
    ------------------------------



  • 3.  RE: pip directing installs in /tmp rather than it's own directory

    ROCKETEER
    Posted 02-15-2024 13:35

    Hello Divyanshu,

    Pip should not usually install packages to /tmp but your setup looks unusual since it looks like you may have actually installed python to /tmp. However, you should note pip almost always needs some space in /tmp to hold temporary files that it creates during the downloading and installation process, if there is no space in /tmp, you can set the TMPDIR environment variable to a path on a filesystem that you know to have space, for example `export TMPDIR=$HOME/.tmp`.

    As for how to change the installation directory of Python, if you're on z/OS I would suggest using the `mv` command to move your installation somewhere else (example: `mv /SYSTEM/tmp/my_div $HOME/`). z/OS Python is distributed in a pax tarball and is relocatable, so the installation can be moved in the same way as any other directory. If you have moved many other files into the the same directory prefix you have installed your Python installation to, so you are no longer sure of what is part of that Python installation, I would recommend downloading the pax archive from IBM and extracting it in some location of your choosing. If you are not on z/OS and instead on some other unix, I would recommend installing python through your system's package manager, or homebrew if you are on MacOS.

    Regards,

    Giancarlo



    ------------------------------
    Giancarlo Frix
    Software Engineer, Open-Source Porting
    Rocket Software Inc.
    ------------------------------



  • 4.  RE: pip directing installs in /tmp rather than it's own directory

    ROCKETEER
    Posted 02-15-2024 13:37

    Hello Divyanshu,

    It's hard to say the exact reason of the issues without additional details. I can only guess.

    1. It seems that you run the command "python3 -m pip install --upgrade virtualenv" by the user who doesn't have home directory, maybe it is "root" user. So pip is trying to create cache folder in "/tmp" folder instead of the user's home folder by default. But by some reason "/tmp" folder is not writeable for that user, that is why we see the first warning. But that is not critical, just pip cache is not used in your case.
    As for the error "No space left on device" - it looks like there is either no space left on the file system where python is installed ("/shrd/python") or that file system is mounted in read only mode. You can check install location for the packages using the command "python3 -m pip list -v". Anyway, packages should be installed by default into the "/shrd/python" folder, where python is installed, not into the "/tmp" folder. But the install location can be changed if you use "user scheme" for installation: https://pip.pypa.io/en/stable/user_guide/#user-installs.

    2. Maybe the same issue as in the previous step - by some reason "/tmp" folder is not writeable for that user. No other ideas at the moment.

    I think you will be able to avoid some or all issues if you will try to install packages by the user who has its own home directory. Or you just need to change default install location as I mentioned above. And it's not good idea to create virtual environment in "/tmp" folder - that folder can be cleared by the OS at some moment and you will lose all your virtual environments.



    ------------------------------
    Vladimir Kudriakov
    Software Engineer
    Rocket Software
    ------------------------------