Git Product home page Git Product logo

cvmfs-venv's Introduction

cvmfs-venv

DOI

Simple command line utility for getting a Python virtual environment to work with CVMFS LCG views. This is done by adding additional hooks to the Python virtual environment's bin/activate script.

Install

Either clone the repo to your directory or simply download the relevant files and place on PATH

$ mkdir -p ~/.local/bin
$ export PATH=~/.local/bin:"${PATH}"  # If ~/.local/bin not on PATH already
$ curl -sL https://raw.githubusercontent.com/matthewfeickert/cvmfs-venv/main/cvmfs-venv.sh -o ~/.local/bin/cvmfs-venv
$ chmod +x ~/.local/bin/cvmfs-venv

Use

Source the script to create a Python 3 virtual environment that can coexist with a CVMFS LCG view. The default name is venv.

$ cvmfs-venv --help
Usage: cvmfs-venv [-s|--setup] [--no-system-site-packages] [--no-update] [--no-uv] <virtual environment name>

Options:
 -h --help      Print this help message
 -s --setup     String of setup options to be parsed
 --no-system-site-packages
                The venv module '--system-site-packages' option is used by
                default. While it is not recommended, this behavior can be
                disabled through use of this flag.
 --no-update    After venv creation don't update pip, setuptools, and wheel
                to the latest releases. Use of this option is not recommended,
                but is faster.
 --no-uv        After venv creation don't install uv and use it to update pip,
                setuptools, and wheel. By default, uv is installed.

Note: cvmfs-venv extends the Python venv module and so requires Python 3.3+.

Examples:

    * Create a Python 3 virtual environment named 'lcg-example' with the Python
    runtime provided by LCG view 104 on CentOS7.

        setupATLAS -3
        lsetup 'views LCG_104 x86_64-centos7-gcc12-opt'
        cvmfs-venv lcg-example
        . lcg-example/bin/activate

    * Create a Python 3 virtual environment named 'atlas-ab-example' with the
    Python runtime provided by ATLAS AnalysisBase release v24.2.30.

        setupATLAS -3
        asetup AnalysisBase,24.2.30
        cvmfs-venv atlas-ab-example
        . atlas-ab-example/bin/activate

    * Create a Python 3 virtual environment named 'venv' with whatever Python
    runtime "\$(command -v python3)" evaluates to.

        cvmfs-venv
        . venv/bin/activate

    * Setup LCG view 104 on CentOS7 and create a Python virtual environment
    named 'lcg-example' using the Python 3.9 runtime it provides.

        . cvmfs-venv --setup "lsetup 'views LCG_104 x86_64-centos7-gcc12-opt'" lcg-example

    * Setup ATLAS AnalysisBase release v24.2.30 and create a Python virtual
    environment named 'atlas-ab-example' using the Python 3.9 runtime it
    provides.

        . cvmfs-venv --setup 'asetup AnalysisBase,24.2.30' atlas-ab-example

Example: Virtual environment with LCG view

$ ssh lxplus
[feickert@lxplus924 ~]$ mkdir -p ~/.local/bin
[feickert@lxplus924 ~]$ export PATH=~/.local/bin:"${PATH}"
[feickert@lxplus924 ~]$ curl -sL https://raw.githubusercontent.com/matthewfeickert/cvmfs-venv/main/cvmfs-venv.sh -o ~/.local/bin/cvmfs-venv
[feickert@lxplus924 ~]$ chmod +x ~/.local/bin/cvmfs-venv
[feickert@lxplus924 ~]$ setupATLAS -3 --quiet
[feickert@lxplus924 ~]$ lsetup 'views LCG_105 x86_64-el9-gcc12-opt'
************************************************************************
Requested:  views ...
 Setting up views LCG_104:x86_64-centos7-gcc12-opt ...
>>>>>>>>>>>>>>>>>>>>>>>>> Information for user <<<<<<<<<<<<<<<<<<<<<<<<<
************************************************************************
[feickert@lxplus924 ~]$ cvmfs-venv lcg-example
# Creating new Python virtual environment 'lcg-example'
[feickert@lxplus924 ~]$ . lcg-example/bin/activate
(lcg-example) [feickert@lxplus924 ~]$ python -m pip list --local  # Show installed defaults
Package    Version
---------- -------
pip        24.0
setuptools 69.5.1
uv         0.1.42
wheel      0.43.0
(lcg-example) [feickert@lxplus924 ~]$ python -m pip show hepdata-lib  # Still have full LCG view
Name: hepdata-lib
Version: 0.12.0
Summary: Library for getting your data into HEPData
Home-page: https://github.com/HEPData/hepdata_lib
Author: Andreas Albert, Clemens Lange
Author-email: [email protected]
License: UNKNOWN
Location: /cvmfs/sft.cern.ch/lcg/views/LCG_105/x86_64-el9-gcc12-opt/lib/python3.9/site-packages
Requires: future, hepdata-validator, numpy, PyYAML
Required-by:
(lcg-example) [feickert@lxplus924 ~]$ uv pip install --upgrade awkward
(lcg-example) [feickert@lxplus924 ~]$ python
Python 3.9.12 (main, Jul 11 2023, 14:44:04)
[GCC 12.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ROOT
>>> import XRootD
>>> import awkward
>>> exit()
(lcg-example) [feickert@lxplus924 ~]$ python -m pip show awkward  # Get version installed in venv
Name: awkward
Version: 2.6.4
Summary: Manipulate JSON-like data with NumPy-like idioms.
Home-page:
Author:
Author-email: Jim Pivarski <[email protected]>
License: BSD-3-Clause
Location: /afs/cern.ch/user/f/feickert/lcg-example/lib/python3.9/site-packages
Requires: awkward-cpp, fsspec, importlib-metadata, numpy, packaging, typing-extensions
Required-by: cabinetry, coffea, servicex, uproot_browser
(lcg-example) [feickert@lxplus924 ~]$ python -m pip list --local  # View of virtual environment controlled packages
Package            Version
------------------ --------
awkward            2.6.4
awkward-cpp        33
fsspec             2024.3.1
importlib_metadata 7.1.0
numpy              1.26.4
packaging          24.0
pip                24.0
setuptools         69.5.1
typing_extensions  4.11.0
uv                 0.1.42
wheel              0.43.0
zipp               3.18.1
(lcg-example) [feickert@lxplus924 ~]$ uv pip list  # uv will show the same view
Package            Version
------------------ --------
awkward            2.6.4
awkward-cpp        33
fsspec             2024.3.1
importlib-metadata 7.1.0
numpy              1.26.4
packaging          24.0
pip                24.0
setuptools         69.5.1
typing-extensions  4.11.0
uv                 0.1.42
wheel              0.43.0
zipp               3.18.1
(lcg-example) [feickert@lxplus924 ~]$ deactivate  # Resets PYTHONPATH given added hooks
[feickert@lxplus924 ~]$ python -m pip show awkward  # Get CVMFS's old version
Name: awkward
Version: 1.10.3
Summary: Manipulate JSON-like data with NumPy-like idioms.
Home-page: https://github.com/scikit-hep/awkward-1.0
Author: Jim Pivarski
Author-email: [email protected]
License: BSD-3-Clause
Location: /cvmfs/sft.cern.ch/lcg/views/LCG_105/x86_64-el9-gcc12-opt/lib/python3.9/site-packages
Requires: numpy, packaging
Required-by: cabinetry, coffea, servicex, uproot_browser

Dependencies

cvmfs-venv has no dependencies beyond the ones it aims to extend: A Linux operating system that has CVMFS installed on it with a Python 3.3+ runtime with a functioning venv module.

A full listing of all programs used outside of Bash shell builtins are:

  • cat
  • ed
  • find
  • readlink
  • sed
  • Python 3.3+ with pip

Why is this needed?

When an LCG view or an ATLAS computing environment that uses software from CVFMS is setup, it manipulates and alters the PYTHONPATH environment variable. By placing the contents of all the installed software of an LCG view or ATLAS release onto PYTHONPATH for the rest of the shell session, the protections and isolation of a Python virtual environment are broken. It is not possible to fix this in a reliable and robust way that will not break the access of other software in the LCG view or ATLAS environment dependent on the Python packages in them. The best that can be done is to control the directory tree at the head of PYTHONPATH in a stable manner that allows for most of the benefits of a Python virtual environment (control of install and versions of packages, isolation of directory tree).

While lcgenv allows for package specific environment building, it still lacks the control to specify arbitrary versions of Python packages and will load additional libraries beyond what is strictly required by the target package dependency requirements. That being said, if you are able to use an LCG view or lcgenv without any additional setup, you may not have need of specifying a Python virtual environment.

While Python's venv module does have the --system-site-packages option to

Give the virtual environment access to the system site-packages dir.

this unfortunately isn't quite enough. It does allow for isolation to work, but the manipulation of PYTHONPATH makes it so that while packages can be installed properly in the local virtual environment and will show up with python -m pip list if there is another version of that package provided by the already setup environment that package version's location on PYTHONPATH will take precedence. Using --system-site-packages without cvmfs-venv is arguably even worse as it provides confusing differences in information between what pip has purported to install in the user's virtual environment and the user pip list view and the runtime environment.

Caveat: This is an LCG view specific issue mostly. If nothing from LCG is used (like a pure ATLAS AnalysisBase environment, or an environment in a Linux container) then --system-site-packages by itself should be sufficient.

How things work

cvmfs-venv provides a shim layer to manage activation and use of a Python virtual environment created with LCG view resources. It does this by copying the structure of the activate scripts generated by Python's venv module. When venv creates a virtual environment it generates a shell script under the virtual environment's directory tree at bin/activate. This activate script controls and edits the shell environmental variables PATH and PYTHONHOME — placing the virtual environment's bin/ directory onto PATH and unsetting PYTHONHOME upon activation, and restoring their original values when deactivate is run. cvmfs-venv simply extends this existing behavior to also place the virtual environment's site-packages/ directory onto PYTHONPATH during activation and to remove it on deactivation. This is done by injecting Bash snippets directly into the bin/activate script generated by venv at positions found relative to the manipulation of PYTHONHOME.

Advantages

  • As cvmfs-venv is just altering the contents of the venv virtual environment's bin/activate script it is extending existing functionality and not trying to remake virtual environments.

  • Once the virtual environment is setup and modified there is no additional dependency on the cvmfs-venv script that generated it.

    • While it saves time it is not needed. You can setup the environment again without it.
    $ . cvmfs-venv --setup "lsetup 'views LCG_104 x86_64-centos7-gcc12-opt'" venv

    vs.

    $ setupATLAS -3
    $ lsetup "views LCG_104 x86_64-centos7-gcc12-opt"
    $ . venv/bin/activate
  • As the virtual environment is prepended to PYTHONPATH all packages installed in the virtual environment are automatically given higher precedence over existing packages of the same name found in the LCG view.

    • If a package named awkward is found in the venv virtual environment and in the LCG view, import awkward with import it from the virtual environment.
  • Python packages not installed in the venv virtual environment but installed in the LCG view (e.g. ROOT, XRootD) can still be accessed inside of the virtual environment.

    • N.B.: This is considered a "advantage" loosely, as it is only happening as a side effect of the isolation of the virtual environment being broken by the LCG view's PYTHONPATH manipulation.
  • Through additional manipulation of PYTHONPATH and PATH with the added cvmfs-venv-rebase functionality, any software added to PATH or PYTHONPATH (e.g., by CVMFS or ATLAS software) while the virtual environment is active will persist on PATH or PYTHONPATH when the virtual environment is deactivated, allowing for a smoother interactive experience.

    • Example: If you want to use rucio both inside and outside of the virtual environment you can set it up either before sourcing the bin/activate script
    $ setupATLAS -3
    $ lsetup "views LCG_104 x86_64-centos7-gcc12-opt"
    $ lsetup "rucio -w"  # PYTHONPATH is altered by lsetup
    $ command -v rucio  # rucio is found
    $ . venv/bin/activate
    (venv) $ command -v rucio  # rucio is found
    (venv) $ deactivate
    $ command -v rucio  # rucio is found

    or after, as cvmfs-venv-rebase will update path variables and keep the virtual environment's directory trees at the heads.

    $ setupATLAS -3
    $ lsetup "views LCG_104 x86_64-centos7-gcc12-opt"
    $ . venv/bin/activate
    (venv) $ lsetup "rucio -w"  # PYTHONPATH is altered by lsetup
    (venv) $ command -v rucio  # rucio is found
    (venv) $ deactivate  # deactivate calls cvmfs-venv-rebase to persist non-venv paths
    $ command -v rucio  # rucio is found

Disadvantages

  • The isolation of a Python virtual environment is not recovered. Python packages installed in the LCG view can still be accessed inside of the virtual environment. This can result in packages from the LCG view meeting requirements of other dependencies during a package install or upgrade (depending on the upgrade strategy) and installing older versions then expected.
    • Suggestion: When installing or upgrading with pip use the --ignore-installed flag.
    • Suggestion: When using pip list to inspect installed packages, use the --local flag to not list packages from the LCG view.
    (venv) $ python -m pip list --local
    
  • As the Python version tied to the virtual environment is provided by LCG view, any changes to the LCG view version require setting up the Python virtual environment from scratch.
    • It is highly advised that your environment be controlled with strict requirements.txt and lock files (e.g. generated from pip-tools using pip-compile) making it reproducible and easy to setup again as a consequence.
    • Example:
    (venv) $ python -m pip install --upgrade pip-tools
    (venv) $ echo "scipy==1.11.3" > requirements.txt  # define high level requirements
    (venv) $ pip-compile --generate-hashes --output-file requirements.lock requirements.txt  # Generate full environment lock file
    (venv) $ python -m pip install --no-deps --require-hashes --only-binary :all: --requirement requirements.lock  # secure-install for reproducibility
  • Having all of the environment manipulation happen inside of the venv's bin/activate script means that the virtual environment needs to be activated after any LCG view or ATLAS software (which make PYTHONPATH not empty) to trigger PYTHONPATH manipulation. This essentially means that the virtual environment must not be activated first in any setup script.

Citation

The preferred BibTeX entry for citation of cvmfs-venv is

@software{cvmfs-venv,
  author = {Matthew Feickert},
  title = "{cvmfs-venv: v0.0.6}",
  version = {0.0.6},
  doi = {10.5281/zenodo.7751033},
  url = {https://doi.org/10.5281/zenodo.7751033},
  note = {https://github.com/matthewfeickert/cvmfs-venv/releases/tag/v0.0.6}
}

cvmfs-venv's People

Contributors

matthewfeickert avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

cvmfs-venv's Issues

Ask on Python discourse how `--system-site-packages` and `PYTHONPATH` interact

This is a TODO item: Find out why in some circumstances (e.g. an ATLAS AnalysisBase release) the use of --system-site-packages is sufficient even though precedence on PYTHONPATH of the virtual environment is low, but in other circumstances (e.g. LCG view you need to hack back PYTHONPATH to have control). Basically understand how --system-site-packages works and exactly how PYTHONPATH works with pip.

Update examples to use el9

cvmfs-venv/README.md

Lines 24 to 77 in b098151

```console
$ cvmfs-venv --help
Usage: cvmfs-venv [-s|--setup] [--no-system-site-packages] [--no-update] [--no-uv] <virtual environment name>
Options:
-h --help Print this help message
-s --setup String of setup options to be parsed
--no-system-site-packages
The venv module '--system-site-packages' option is used by
default. While it is not recommended, this behavior can be
disabled through use of this flag.
--no-update After venv creation don't update pip, setuptools, and wheel
to the latest releases. Use of this option is not recommended,
but is faster.
--no-uv After venv creation don't install uv and use it to update pip,
setuptools, and wheel. By default, uv is installed.
Note: cvmfs-venv extends the Python venv module and so requires Python 3.3+.
Examples:
* Create a Python 3 virtual environment named 'lcg-example' with the Python
runtime provided by LCG view 104 on CentOS7.
setupATLAS -3
lsetup 'views LCG_104 x86_64-centos7-gcc12-opt'
cvmfs-venv lcg-example
. lcg-example/bin/activate
* Create a Python 3 virtual environment named 'atlas-ab-example' with the
Python runtime provided by ATLAS AnalysisBase release v24.2.30.
setupATLAS -3
asetup AnalysisBase,24.2.30
cvmfs-venv atlas-ab-example
. atlas-ab-example/bin/activate
* Create a Python 3 virtual environment named 'venv' with whatever Python
runtime "\$(command -v python3)" evaluates to.
cvmfs-venv
. venv/bin/activate
* Setup LCG view 104 on CentOS7 and create a Python virtual environment
named 'lcg-example' using the Python 3.9 runtime it provides.
. cvmfs-venv --setup "lsetup 'views LCG_104 x86_64-centos7-gcc12-opt'" lcg-example
* Setup ATLAS AnalysisBase release v24.2.30 and create a Python virtual
environment named 'atlas-ab-example' using the Python 3.9 runtime it
provides.
. cvmfs-venv --setup 'asetup AnalysisBase,24.2.30' atlas-ab-example
```

and

cvmfs-venv/cvmfs-venv.sh

Lines 25 to 58 in b098151

Examples:
* Create a Python 3 virtual environment named 'lcg-example' with the Python
runtime provided by LCG view 104 on CentOS7.
setupATLAS -3
lsetup 'views LCG_104 x86_64-centos7-gcc12-opt'
cvmfs-venv lcg-example
. lcg-example/bin/activate
* Create a Python 3 virtual environment named 'atlas-ab-example' with the
Python runtime provided by ATLAS AnalysisBase release v24.2.30.
setupATLAS -3
asetup AnalysisBase,24.2.30
cvmfs-venv atlas-ab-example
. atlas-ab-example/bin/activate
* Create a Python 3 virtual environment named 'venv' with whatever Python
runtime "\$(command -v python3)" evaluates to.
cvmfs-venv
. venv/bin/activate
* Setup LCG view 104 on CentOS7 and create a Python virtual environment
named 'lcg-example' using the Python 3.9 runtime it provides.
. cvmfs-venv --setup "lsetup 'views LCG_104 x86_64-centos7-gcc12-opt'" lcg-example
* Setup ATLAS AnalysisBase release v24.2.30 and create a Python virtual
environment named 'atlas-ab-example' using the Python 3.9 runtime it
provides.
. cvmfs-venv --setup 'asetup AnalysisBase,24.2.30' atlas-ab-example

should get updated to use el9.

Add CMS example

@kpedro88 @nsmith- Can I get you to give me an example of how CMS uses CVMFS to setup environments similar to

cvmfs-venv/README.md

Lines 61 to 66 in 41f05ce

* Create a Python 3 virtual environment named 'alrb-example' with the Python
runtime provided by ATLAS AnalysisBase release v22.2.113.
setupATLAS -3
asetup AnalysisBase,22.2.113
. cvmfs-venv alrb-example

so that I could add an example to the --help option?

Failing to work on top of ATLAS StatAnalysis

Will Buttinger has pointed out that even though cvmfs-venv works for LCG views and AnalysisBase environments it is failing to work as expected for StatAnalysis. So something about the way StatAnalysis sets up its environment is different compared to LCG views and AnalysisBase. This would be good to guard against and support.

Minimal Failing Example

Using 759cbd0

#!/bin/bash

mkdir -p ~/.local/bin
export PATH=~/.local/bin:"${PATH}"  # If ~/.local/bin not on PATH already
curl -sL https://raw.githubusercontent.com/matthewfeickert/cvmfs-venv/759cbd066026f2209b6f541baf3f41085bfc1620/cvmfs-venv.sh -o ~/.local/bin/cvmfs-venv
chmod +x ~/.local/bin/cvmfs-venv

# Guard against this being run in a subshell
export ATLAS_LOCAL_ROOT_BASE=/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase
. "${ATLAS_LOCAL_ROOT_BASE}/user/atlasLocalSetup.sh" -3  # setuptATLAS

echo "# asetup StatAnalysis,latest,master"
asetup StatAnalysis,latest,master
echo "PATH=$PATH"
echo "PYTHONPATH=$PYTHONPATH"
echo "$ python3: $(command -v python3)"
echo "# python3 --version --version"
python3 --version --version
echo "# python3 -m pip list | wc -l"
python3 -m pip list | wc -l
echo "# python3 -c 'import numpy; print(numpy)'"
python3 -c 'import numpy; print(numpy)'

echo ""
python3 -m venv failing-example
. cvmfs-venv working-example
echo "PATH=$PATH"
echo "PYTHONPATH=$PYTHONPATH"
echo "# python -m pip list"
python -m pip list
echo "# python -c 'import numpy; print(numpy)'"
python -c 'import numpy; print(numpy)'

Relevant output:

# asetup StatAnalysis,latest,master
Using StatAnalysis/0.2.0 [cmake] with platform x86_64-centos7-gcc11-opt
	at /cvmfs/atlas-nightlies.cern.ch/repo/sw/master_StatAnalysis_x86_64-centos7-gcc11-opt/2023-03-20T2101
StatAnalysis Software Versions (Please ask sw developers to submit updates):

ROOT                : v6-28-00
Python              : 3.10.6
RooFitExtensions    : v1.0.4 2023-03-14 16:11:29 +0100
xRooFit             : b8c8a621 2023-03-14 10:33:22 +0000
TRExFitter          : f3a290a7 2023-02-14 18:41:44 +0100
quickFit            :  
RooUnfold           : 924c8b60 2022-07-18 14:52:20 +0200
xmlAnaWSBuilder     : a89c1178 2023-03-15 03:36:35 +0100
workspaceCombiner   : 8c0a7050 2022-03-27 08:29:01 +0200
HistFitter          :  
BootstrapGenerator  : 71e6ebe2 2021-12-10 20:25:28 +0100
Significance        : d59b9a2 2023-03-14 12:30:24 +0000
pyhf                : 0.7.0
Unchanged: COOL_ORA_ENABLE_ADAPTIVE_OPT=Y
PATH=/tmp/feickert/.asetup-sysbin-TokIPE_4156917:/cvmfs/atlas-nightlies.cern.ch/repo/sw/master_StatAnalysis_x86_64-centos7-gcc11-opt/2023-03-20T2101/StatAnalysis/0.2.0/InstallArea/x86_64-centos7-gcc11-opt/share:/cvmfs/atlas-nightlies.cern.ch/repo/sw/master_StatAnalysis_x86_64-centos7-gcc11-opt/2023-03-20T2101/StatAnalysis/0.2.0/InstallArea/x86_64-centos7-gcc11-opt/bin:/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/Cmake/3.24.3/Linux-x86_64/bin:/cvmfs/sft.cern.ch/lcg/releases/gcc/11.2.0-8a51a/x86_64-centos7/bin:/cvmfs/sft.cern.ch/lcg/releases/binutils/2.37-355ed/x86_64-centos7/bin:/home/feickert/.local/bin:/home/feickert/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/opt/puppetlabs/bin:/opt/dell/srvadmin/bin
PYTHONPATH=/cvmfs/atlas-nightlies.cern.ch/repo/sw/master_StatAnalysis_x86_64-centos7-gcc11-opt/2023-03-20T2101/StatAnalysis/0.2.0/InstallArea/x86_64-centos7-gcc11-opt/python:/cvmfs/atlas-nightlies.cern.ch/repo/sw/master_StatAnalysis_x86_64-centos7-gcc11-opt/2023-03-20T2101/StatAnalysis/0.2.0/InstallArea/x86_64-centos7-gcc11-opt/lib
$ python3: /cvmfs/atlas-nightlies.cern.ch/repo/sw/master_StatAnalysis_x86_64-centos7-gcc11-opt/2023-03-20T2101/StatAnalysis/0.2.0/InstallArea/x86_64-centos7-gcc11-opt/bin/python3
# python3 --version --version
Python 3.10.6 (main, Mar 16 2023, 21:14:05) [GCC 11.2.0]
# python3 -m pip list | wc -l
55
# python3 -c 'import numpy; print(numpy)'
<module 'numpy' from '/cvmfs/atlas-nightlies.cern.ch/repo/sw/master_StatAnalysis_x86_64-centos7-gcc11-opt/2023-03-20T2101/StatAnalysis/0.2.0/InstallArea/x86_64-centos7-gcc11-opt/lib/python3.10/site-packages/numpy-1.22.3-py3.10-linux-x86_64.egg/numpy/__init__.py'>

# Creating new Python virtual environment 'working-example'
PATH=/tmp/feickert/working-example/bin:/tmp/feickert/.asetup-sysbin-TokIPE_4156917:/cvmfs/atlas-nightlies.cern.ch/repo/sw/master_StatAnalysis_x86_64-centos7-gcc11-opt/2023-03-20T2101/StatAnalysis/0.2.0/InstallArea/x86_64-centos7-gcc11-opt/share:/cvmfs/atlas-nightlies.cern.ch/repo/sw/master_StatAnalysis_x86_64-centos7-gcc11-opt/2023-03-20T2101/StatAnalysis/0.2.0/InstallArea/x86_64-centos7-gcc11-opt/bin:/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/Cmake/3.24.3/Linux-x86_64/bin:/cvmfs/sft.cern.ch/lcg/releases/gcc/11.2.0-8a51a/x86_64-centos7/bin:/cvmfs/sft.cern.ch/lcg/releases/binutils/2.37-355ed/x86_64-centos7/bin:/home/feickert/.local/bin:/home/feickert/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/opt/puppetlabs/bin:/opt/dell/srvadmin/bin
PYTHONPATH=/tmp/feickert/working-example/lib/python3.10/site-packages:/cvmfs/atlas-nightlies.cern.ch/repo/sw/master_StatAnalysis_x86_64-centos7-gcc11-opt/2023-03-20T2101/StatAnalysis/0.2.0/InstallArea/x86_64-centos7-gcc11-opt/python:/cvmfs/atlas-nightlies.cern.ch/repo/sw/master_StatAnalysis_x86_64-centos7-gcc11-opt/2023-03-20T2101/StatAnalysis/0.2.0/InstallArea/x86_64-centos7-gcc11-opt/lib
# python -m pip list
Package    Version
---------- -------
pip        23.0.1
setuptools 67.6.0
wheel      0.40.0
# python -c 'import numpy; print(numpy)'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'numpy'

Minimal Working Example with AnalysisBase

Using 759cbd0

#!/bin/bash

mkdir -p ~/.local/bin
export PATH=~/.local/bin:"${PATH}"  # If ~/.local/bin not on PATH already
curl -sL https://raw.githubusercontent.com/matthewfeickert/cvmfs-venv/759cbd066026f2209b6f541baf3f41085bfc1620/cvmfs-venv.sh -o ~/.local/bin/cvmfs-venv
chmod +x ~/.local/bin/cvmfs-venv

# Guard against this being run in a subshell
export ATLAS_LOCAL_ROOT_BASE=/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase
. "${ATLAS_LOCAL_ROOT_BASE}/user/atlasLocalSetup.sh" -3  # setuptATLAS

echo "# asetup AnalysisBase,22.2.113"
asetup AnalysisBase,22.2.113
echo "PATH=$PATH"
echo "PYTHONPATH=$PYTHONPATH"
echo "$ python3: $(command -v python3)"
echo "# python3 --version --version"
python3 --version --version
echo "# python3 -m pip list | wc -l"
python3 -m pip list | wc -l
echo "# python3 -c 'import numpy; print(numpy)'"
python3 -c 'import numpy; print(numpy)'

echo ""
. cvmfs-venv ab-working-example
echo "PATH=$PATH"
echo "PYTHONPATH=$PYTHONPATH"
echo "# python -m pip list"
python -m pip list
echo "# python -c 'import numpy; print(numpy)'"
python -c 'import numpy; print(numpy)'

Relevant output:

# asetup AnalysisBase,22.2.113
Using AnalysisBase/22.2.113 [cmake] with platform x86_64-centos7-gcc11-opt
	at /cvmfs/atlas.cern.ch/repo/sw/software/22.2
Unchanged: COOL_ORA_ENABLE_ADAPTIVE_OPT=Y
PATH=/tmp/feickert/.asetup-sysbin-lkkd3E_2481758:/cvmfs/atlas.cern.ch/repo/sw/software/22.2/AnalysisBase/22.2.113/InstallArea/x86_64-centos7-gcc11-opt/share:/cvmfs/atlas.cern.ch/repo/sw/software/22.2/AnalysisBase/22.2.113/InstallArea/x86_64-centos7-gcc11-opt/bin:/cvmfs/atlas.cern.ch/repo/sw/software/22.2/AnalysisBaseExternals/22.2.113/InstallArea/x86_64-centos7-gcc11-opt/bin:/cvmfs/atlas.cern.ch/repo/sw/software/22.2/AnalysisBaseExternals/22.2.113/InstallArea/x86_64-centos7-gcc11-opt/share:/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/Cmake/3.24.3/Linux-x86_64/bin:/cvmfs/sft.cern.ch/lcg/releases/gcc/11.2.0-8a51a/x86_64-centos7/bin:/cvmfs/sft.cern.ch/lcg/releases/binutils/2.37-355ed/x86_64-centos7/bin:/home/feickert/.local/bin:/home/feickert/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/opt/puppetlabs/bin:/opt/dell/srvadmin/bin
PYTHONPATH=/cvmfs/atlas.cern.ch/repo/sw/software/22.2/AnalysisBase/22.2.113/InstallArea/x86_64-centos7-gcc11-opt/python:/cvmfs/atlas.cern.ch/repo/sw/software/22.2/AnalysisBase/22.2.113/InstallArea/x86_64-centos7-gcc11-opt/lib:/cvmfs/atlas.cern.ch/repo/sw/software/22.2/AnalysisBaseExternals/22.2.113/InstallArea/x86_64-centos7-gcc11-opt/lib:/cvmfs/atlas.cern.ch/repo/sw/software/22.2/AnalysisBaseExternals/22.2.113/InstallArea/x86_64-centos7-gcc11-opt/python:/cvmfs/atlas.cern.ch/repo/sw/software/22.2/AnalysisBaseExternals/22.2.113/InstallArea/x86_64-centos7-gcc11-opt/lib/python3.9/site-packages
$ python3: /cvmfs/atlas.cern.ch/repo/sw/software/22.2/AnalysisBaseExternals/22.2.113/InstallArea/x86_64-centos7-gcc11-opt/bin/python3
# python3 --version --version
Python 3.9.12 (main, Mar 16 2023, 02:25:00) 
[GCC 11.2.0]
# python3 -m pip list | wc -l
9
# python3 -c 'import numpy; print(numpy)'
<module 'numpy' from '/cvmfs/atlas.cern.ch/repo/sw/software/22.2/AnalysisBaseExternals/22.2.113/InstallArea/x86_64-centos7-gcc11-opt/lib/python3.9/site-packages/numpy-1.22.3-py3.9-linux-x86_64.egg/numpy/__init__.py'>

# Creating new Python virtual environment 'ab-working-example'
PATH=/tmp/feickert/ab-working-example/bin:/tmp/feickert/.asetup-sysbin-lkkd3E_2481758:/cvmfs/atlas.cern.ch/repo/sw/software/22.2/AnalysisBase/22.2.113/InstallArea/x86_64-centos7-gcc11-opt/share:/cvmfs/atlas.cern.ch/repo/sw/software/22.2/AnalysisBase/22.2.113/InstallArea/x86_64-centos7-gcc11-opt/bin:/cvmfs/atlas.cern.ch/repo/sw/software/22.2/AnalysisBaseExternals/22.2.113/InstallArea/x86_64-centos7-gcc11-opt/bin:/cvmfs/atlas.cern.ch/repo/sw/software/22.2/AnalysisBaseExternals/22.2.113/InstallArea/x86_64-centos7-gcc11-opt/share:/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/Cmake/3.24.3/Linux-x86_64/bin:/cvmfs/sft.cern.ch/lcg/releases/gcc/11.2.0-8a51a/x86_64-centos7/bin:/cvmfs/sft.cern.ch/lcg/releases/binutils/2.37-355ed/x86_64-centos7/bin:/home/feickert/.local/bin:/home/feickert/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/opt/puppetlabs/bin:/opt/dell/srvadmin/bin
PYTHONPATH=/tmp/feickert/ab-working-example/lib/python3.9/site-packages:/cvmfs/atlas.cern.ch/repo/sw/software/22.2/AnalysisBase/22.2.113/InstallArea/x86_64-centos7-gcc11-opt/python:/cvmfs/atlas.cern.ch/repo/sw/software/22.2/AnalysisBase/22.2.113/InstallArea/x86_64-centos7-gcc11-opt/lib:/cvmfs/atlas.cern.ch/repo/sw/software/22.2/AnalysisBaseExternals/22.2.113/InstallArea/x86_64-centos7-gcc11-opt/lib:/cvmfs/atlas.cern.ch/repo/sw/software/22.2/AnalysisBaseExternals/22.2.113/InstallArea/x86_64-centos7-gcc11-opt/python:/cvmfs/atlas.cern.ch/repo/sw/software/22.2/AnalysisBaseExternals/22.2.113/InstallArea/x86_64-centos7-gcc11-opt/lib/python3.9/site-packages
# python -m pip list
Package    Version
---------- -------
Cython     0.29.28
LHAPDF     6.5.1
numpy      1.22.3
pip        23.0.1
setuptools 67.6.0
wheel      0.40.0
xrootd     5.4.3
# python -c 'import numpy; print(numpy)'
<module 'numpy' from '/cvmfs/atlas.cern.ch/repo/sw/software/22.2/AnalysisBaseExternals/22.2.113/InstallArea/x86_64-centos7-gcc11-opt/lib/python3.9/site-packages/numpy-1.22.3-py3.9-linux-x86_64.egg/numpy/__init__.py'>

Use sed over ed

In el9 ed isn't a guarantee, so check if ed is available and if not use sed.

Add option to work with AnalysisBase

To be more useful this should also work with ATLAS AnlaysisBase (both release 21 and release 22).

Just the following diff gets things working for AnalysisBase 22.2.61

diff --git a/atlas_setup.sh b/atlas_setup.sh
index 3ef41a7..2908e95 100644
--- a/atlas_setup.sh
+++ b/atlas_setup.sh
@@ -19,8 +19,14 @@ if [ "$(python3 -c 'from platform import platform; print("centos-8" in platform(
     default_LCG_release="LCG_100"
     default_LCG_platform="x86_64-centos8-gcc10-opt"
 fi
-printf "\nlsetup 'views %s %s'\n" "${default_LCG_release}" "${default_LCG_platform}"
-lsetup "views ${default_LCG_release} ${default_LCG_platform}"
+# printf "\nlsetup 'views %s %s'\n" "${default_LCG_release}" "${default_LCG_platform}"
+# lsetup "views ${default_LCG_release} ${default_LCG_platform}"
+
+# _ATLAS_RELEASE="21.2.203"
+_ATLAS_RELEASE="22.2.61"
+printf "\nasetup %s,AnalysisBase\n" "${_ATLAS_RELEASE}"
+asetup "${_ATLAS_RELEASE},AnalysisBase"
+unset _ATLAS_RELEASE
 
 _venv_name="${1:-venv}"
 if [ ! -d "${_venv_name}" ]; then
Example with AnalysisBase 22.2.61:
(base) feickert@ThinkPad-X1:~$ ssh uchicago 
Last login: Fri Feb 11 15:02:28 2022 from 216.169.6.123
    _ _____ _      _   ___ 
   /_\_   _| |    /_\ / __|
  / _ \| | | |__ / _ \\__ \
 /_/ \_\_| |____/_/ \_\___/
Analysis Facility at UChicago
-----------------------------

-====== DOCUMENTATION ======-
Read the Docs: 
  https://usatlas.readthedocs.io/projects/af-docs/en/latest/

-======== SUPPORT ==========-
Discourse:
  https://atlas-talk.web.cern.ch/c/us-tier-3-user-support/
Admin list:
  [email protected]

File system quota report
╒════════╤══════════════╤══════════════╤═════════════╤═════════════╕
│ Path   │   Usage (GB) │   Limit (GB) │   Files (#) │   Quota (%) │
╞════════╪══════════════╪══════════════╪═════════════╪═════════════╡
│ /home  │         5.83 │          100 │       52075 │        5.83 │
├────────┼──────────────┼──────────────┼─────────────┼─────────────┤
│ /data  │         0.2  │         5120 │        1714 │        0    │
╘════════╧══════════════╧══════════════╧═════════════╧═════════════╛

[15:19] login02.af.uchicago.edu:~ $ cd debug/
# Get patched file
[15:20] login02.af.uchicago.edu:~/debug $ . atlas_setup.sh 

asetup 22.2.61,AnalysisBase
Using AnalysisBase/22.2.61 [cmake] with platform x86_64-centos7-gcc11-opt
	at /cvmfs/atlas.cern.ch/repo/sw/software/22.2
Unchanged: COOL_ORA_ENABLE_ADAPTIVE_OPT=Y
# Creating new Python virtual environment 'venv'
(venv) [15:20] login02.af.uchicago.edu:~/debug $ echo $PYTHONPATH
/home/feickert/debug/venv/lib/python3.9/site-packages:/cvmfs/atlas.cern.ch/repo/sw/software/22.2/AnalysisBase/22.2.61/InstallArea/x86_64-centos7-gcc11-opt/python:/cvmfs/atlas.cern.ch/repo/sw/software/22.2/AnalysisBase/22.2.61/InstallArea/x86_64-centos7-gcc11-opt/lib:/cvmfs/atlas.cern.ch/repo/sw/software/22.2/AnalysisBaseExternals/22.2.61/InstallArea/x86_64-centos7-gcc11-opt/lib:/cvmfs/atlas.cern.ch/repo/sw/software/22.2/AnalysisBaseExternals/22.2.61/InstallArea/x86_64-centos7-gcc11-opt/python:/cvmfs/atlas.cern.ch/repo/sw/software/22.2/AnalysisBaseExternals/22.2.61/InstallArea/x86_64-centos7-gcc11-opt/lib/python3.9/site-packages
(venv) [15:20] login02.af.uchicago.edu:~/debug $ command -v python
/home/feickert/debug/venv/bin/python
(venv) [15:20] login02.af.uchicago.edu:~/debug $ python --version
Python 3.9.6
(venv) [15:21] login02.af.uchicago.edu:~/debug $ python -m pip list
Package    Version
---------- -------
Cython     0.29.21
LHAPDF     6.3.0
numpy      1.21.1
pip        22.0.3
setuptools 60.8.2
wheel      0.37.1
xrootd     5.3.1
(venv) [15:21] login02.af.uchicago.edu:~/debug $ python -m pip install awkward
Collecting awkward
  Downloading awkward-1.7.0-cp39-cp39-manylinux2010_x86_64.whl (14.5 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 14.5/14.5 MB 260.0 MB/s eta 0:00:00
Requirement already satisfied: numpy>=1.13.1 in /cvmfs/atlas.cern.ch/repo/sw/software/22.2/AnalysisBaseExternals/22.2.61/InstallArea/x86_64-centos7-gcc11-opt/lib/python3.9/site-packages/numpy-1.21.1-py3.9-linux-x86_64.egg (from awkward) (1.21.1)
Requirement already satisfied: setuptools in ./venv/lib/python3.9/site-packages (from awkward) (60.8.2)
Installing collected packages: awkward
Successfully installed awkward-1.7.0
(venv) [15:22] login02.af.uchicago.edu:~/debug $ python -m pip list
Package    Version
---------- -------
awkward    1.7.0
Cython     0.29.21
LHAPDF     6.3.0
numpy      1.21.1
pip        22.0.3
setuptools 60.8.2
wheel      0.37.1
xrootd     5.3.1
(venv) [15:22] login02.af.uchicago.edu:~/debug $ pip show awkward
Name: awkward
Version: 1.7.0
Summary: Manipulate JSON-like data with NumPy-like idioms.
Home-page: https://github.com/scikit-hep/awkward-1.0
Author: Jim Pivarski
Author-email: [email protected]
License: BSD-3-Clause
Location: /home/feickert/debug/venv/lib/python3.9/site-packages
Requires: numpy, setuptools
Required-by: 
(venv) [15:22] login02.af.uchicago.edu:~/debug $ deactivate 
[15:22] login02.af.uchicago.edu:~/debug $ echo $PYTHONPATH
/cvmfs/atlas.cern.ch/repo/sw/software/22.2/AnalysisBase/22.2.61/InstallArea/x86_64-centos7-gcc11-opt/python:/cvmfs/atlas.cern.ch/repo/sw/software/22.2/AnalysisBase/22.2.61/InstallArea/x86_64-centos7-gcc11-opt/lib:/cvmfs/atlas.cern.ch/repo/sw/software/22.2/AnalysisBaseExternals/22.2.61/InstallArea/x86_64-centos7-gcc11-opt/lib:/cvmfs/atlas.cern.ch/repo/sw/software/22.2/AnalysisBaseExternals/22.2.61/InstallArea/x86_64-centos7-gcc11-opt/python:/cvmfs/atlas.cern.ch/repo/sw/software/22.2/AnalysisBaseExternals/22.2.61/InstallArea/x86_64-centos7-gcc11-opt/lib/python3.9/site-packages
[15:22] login02.af.uchicago.edu:~/debug $ command -v python  
/cvmfs/atlas.cern.ch/repo/sw/software/22.2/AnalysisBaseExternals/22.2.61/InstallArea/x86_64-centos7-gcc11-opt/bin/python
[15:23] login02.af.uchicago.edu:~/debug $ python -m pip list
Package    Version
---------- -------
Cython     0.29.21
LHAPDF     6.3.0
numpy      1.21.1
pip        21.0.1
setuptools 44.1.0
wheel      0.33.4
xrootd     5.3.1

though for AnalysisBase 21 there are problems as things are still Python 2 there. This is a big problem as the venv module wasn't added to Python until Python 3:

$ docker run --rm python:2.7 /bin/bash -c 'python --version --version; python -m venv --help'
Python 2.7.18
/usr/local/bin/python: No module named venv

CVMFS arch is not compatible with modern TensorFlow wheels

CVMFS LCG views have architecture that is not necessarily compliant with modern machine learning library wheels. For an example CVMFS view LCG_98python3 x86_64-centos7-gcc8-opt is copatible with tensorflow v2.1.0 but not tensorflow v2.8.0.

Example

$ ssh uchicago
[17:38] login02.af.uchicago.edu:~ $ mkdir debug && cd debug
[17:38] login02.af.uchicago.edu:~/debug $ curl -sLO https://raw.githubusercontent.com/matthewfeickert/cvmfs-venv/2a6831069b4164925736efc9e4f25549ae831b4a/atlas_setup.sh
[17:38] login02.af.uchicago.edu:~/debug $ . atlas_setup.sh debug
(debug) [17:39] login02.af.uchicago.edu:~/debug $ deactivate
[17:39] login02.af.uchicago.edu:~/debug $ python -m pip show tensorflow
[17:39] login02.af.uchicago.edu:~/debug $ python -m pip show tensorflow-cpu
Name: tensorflow-cpu
Version: 2.1.0
Summary: TensorFlow is an open source machine learning framework for everyone.
Home-page: https://www.tensorflow.org/
Author: Google Inc.
Author-email: [email protected]
License: Apache 2.0
Location: /cvmfs/sft.cern.ch/lcg/views/LCG_98python3/x86_64-centos7-gcc8-opt/lib/python3.7/site-packages
Requires: grpcio, wrapt, opt-einsum, six, gast, wheel, scipy, astor, google-pasta, tensorflow-estimator, tensorboard, keras-preprocessing, protobuf, termcolor, numpy, absl-py, keras-applications
Required-by:
[17:39] login02.af.uchicago.edu:~/debug $ . debug/bin/activate
(debug) [17:39] login02.af.uchicago.edu:~/debug $ python -m pip install --upgrade 'tensorflow==2.1.0'
(debug) [17:39] login02.af.uchicago.edu:~/debug $ python -m pip show tensorflow
Name: tensorflow
Version: 2.1.0
Summary: TensorFlow is an open source machine learning framework for everyone.
Home-page: https://www.tensorflow.org/
Author: Google Inc.
Author-email: [email protected]
License: Apache 2.0
Location: /home/feickert/debug/debug/lib/python3.7/site-packages
Requires: absl-py, astor, gast, google-pasta, grpcio, keras-applications, keras-preprocessing, numpy, opt-einsum, protobuf, scipy, six, tensorboard, tensorflow-estimator, termcolor, wheel, wrapt
Required-by: 
(debug) [17:39] login02.af.uchicago.edu:~/debug $ python -c 'import tensorflow as tf; import keras'
2022-02-10 17:36:11.112165: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'libnvinfer.so.6'; dlerror: libnvinfer.so.6: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /cvmfs/sft.cern.ch/lcg/releases/MCGenerators/thepeg/2.2.1-c1b37/x86_64-centos7-gcc8-opt/lib/ThePEG:/cvmfs/sft.cern.ch/lcg/releases/MCGenerators/herwig++/7.2.1-71099/x86_64-centos7-gcc8-opt/lib/Herwig:/cvmfs/sft.cern.ch/lcg/views/LCG_98python3/x86_64-centos7-gcc8-opt/lib/python3.7/site-packages/torch/lib:/cvmfs/sft.cern.ch/lcg/views/LCG_98python3/x86_64-centos7-gcc8-opt/lib/python3.7/site-packages/tensorflow_core:/cvmfs/sft.cern.ch/lcg/releases/java/8u222-884d8/x86_64-centos7-gcc8-opt/jre/lib/amd64:/cvmfs/sft.cern.ch/lcg/views/LCG_98python3/x86_64-centos7-gcc8-opt/lib64:/cvmfs/sft.cern.ch/lcg/views/LCG_98python3/x86_64-centos7-gcc8-opt/lib:/cvmfs/sft.cern.ch/lcg/releases/gcc/8.3.0-cebb0/x86_64-centos7/lib:/cvmfs/sft.cern.ch/lcg/releases/gcc/8.3.0-cebb0/x86_64-centos7/lib64:/cvmfs/sft.cern.ch/lcg/releases/binutils/2.30-e5b21/x86_64-centos7/lib:/cvmfs/sft.cern.ch/lcg/releases/R/3.6.3-2dabd/x86_64-centos7-gcc8-opt/lib64/R/library/readr/rcon
2022-02-10 17:36:11.112273: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'libnvinfer_plugin.so.6'; dlerror: libnvinfer_plugin.so.6: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /cvmfs/sft.cern.ch/lcg/releases/MCGenerators/thepeg/2.2.1-c1b37/x86_64-centos7-gcc8-opt/lib/ThePEG:/cvmfs/sft.cern.ch/lcg/releases/MCGenerators/herwig++/7.2.1-71099/x86_64-centos7-gcc8-opt/lib/Herwig:/cvmfs/sft.cern.ch/lcg/views/LCG_98python3/x86_64-centos7-gcc8-opt/lib/python3.7/site-packages/torch/lib:/cvmfs/sft.cern.ch/lcg/views/LCG_98python3/x86_64-centos7-gcc8-opt/lib/python3.7/site-packages/tensorflow_core:/cvmfs/sft.cern.ch/lcg/releases/java/8u222-884d8/x86_64-centos7-gcc8-opt/jre/lib/amd64:/cvmfs/sft.cern.ch/lcg/views/LCG_98python3/x86_64-centos7-gcc8-opt/lib64:/cvmfs/sft.cern.ch/lcg/views/LCG_98python3/x86_64-centos7-gcc8-opt/lib:/cvmfs/sft.cern.ch/lcg/releases/gcc/8.3.0-cebb0/x86_64-centos7/lib:/cvmfs/sft.cern.ch/lcg/releases/gcc/8.3.0-cebb0/x86_64-centos7/lib64:/cvmfs/sft.cern.ch/lcg/releases/binutils/2.30-e5b21/x86_64-centos7/lib:/cvmfs/sft.cern.ch/lcg/releases/R/3.6.3-2dabd/x86_64-centos7-gcc8-opt/lib64/R/library/readr/rcon
2022-02-10 17:36:11.112286: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:30] Cannot dlopen some TensorRT libraries. If you would like to use Nvidia GPU with TensorRT, please make sure the missing libraries mentioned above are installed properly.
Using TensorFlow backend.
(debug) $ python -m pip install --upgrade tensorflow
(debug) $ python -m pip show tensorflow
Name: tensorflow
Version: 2.8.0
Summary: TensorFlow is an open source machine learning framework for everyone.
Home-page: https://www.tensorflow.org/
Author: Google Inc.
Author-email: [email protected]
License: Apache 2.0
Location: /home/feickert/debug/debug/lib/python3.7/site-packages
Requires: absl-py, astunparse, flatbuffers, gast, google-pasta, grpcio, h5py, keras, keras-preprocessing, libclang, numpy, opt-einsum, protobuf, setuptools, six, tensorboard, tensorflow-io-gcs-filesystem, termcolor, tf-estimator-nightly, typing-extensions, wrapt
Required-by: 
(debug) [17:40] login02.af.uchicago.edu:~/debug $ python -c 'import tensorflow as tf; import keras'
Traceback (most recent call last):
  File "/home/feickert/debug/debug/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 60, in <module>
    from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: /home/feickert/debug/debug/lib/python3.7/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so: undefined symbol: _ZNK10tensorflow8OpKernel11TraceStringERKNS_15OpKernelContextEb

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/feickert/debug/debug/lib/python3.7/site-packages/tensorflow/__init__.py", line 37, in <module>
    from tensorflow.python.tools import module_util as _module_util
  File "/home/feickert/debug/debug/lib/python3.7/site-packages/tensorflow/python/__init__.py", line 36, in <module>
    from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow
  File "/home/feickert/debug/debug/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 76, in <module>
    f'{traceback.format_exc()}'
ImportError: Traceback (most recent call last):
  File "/home/feickert/debug/debug/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 60, in <module>
    from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: /home/feickert/debug/debug/lib/python3.7/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so: undefined symbol: _ZNK10tensorflow8OpKernel11TraceStringERKNS_15OpKernelContextEb


Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/errors for some common causes and solutions.
If you need help, create an issue at https://github.com/tensorflow/tensorflow/issues and include the entire stack trace above this error message.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.