Answer the question
In order to leave comments, you need to log in
How to properly cut text in bash?
Hello.
In general, I need to pull out the path to site-packages
# /opt/anaconda/envs/py36/bin/python -m site
sys.path = [
'/etc/systemd/system',
'/opt/anaconda/envs/py36/lib/python36.zip',
'/opt/anaconda/envs/py36/lib/python3.6',
'/opt/anaconda/envs/py36/lib/python3.6/lib-dynload',
'/opt/anaconda/envs/py36/lib/python3.6/site-packages',
'/opt/anaconda2/envs/py36/lib/python3.6/site-packages',
]
USER_BASE: '/root/.local' (exists)
USER_SITE: '/root/.local/lib/python3.6/site-packages' (doesn't exist)
ENABLE_USER_SITE: True
/opt/anaconda/envs/py36/bin/python -c "import site; print(site.getsitepackages())"
['/opt/anaconda/envs/py36/lib/python3.6/site-packages']
pathp="/opt/anaconda/envs/py36/bin/python -c \"import site; print(site.getsitepackages())\""
path1=$(eval "$pathp")
path1=$(echo $path1 | cut -c3-)
path1=$(echo $path1 | rev | cut -c3- | rev)
echo $path1
/opt/anaconda/envs/py36/lib/python3.6/site-packages
Answer the question
In order to leave comments, you need to log in
Specifically in your case:
python -c "exec(\"import site\nfor im in site.getsitepackages():print(im)\")"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question