如果我使用Ubuntu 18.04创建virtualenv,则会创建一个名为local
的目录。
virtualenv test-env
cd test-env
ls -l local/
输出:
lrwxrwxrwx 1 foo foo 30 Jan 30 10:47 bin -> /home/foo/tmp/test-env/bin
lrwxrwxrwx 1 foo foo 34 Jan 30 10:47 include -> /home/foo/tmp/test-env/include
lrwxrwxrwx 1 foo foo 30 Jan 30 10:47 lib -> /home/foo/tmp/test-env/lib
版本:
virtualenv --version
15.0.3
在其他计算机(例如企业SuSE Linux)上不会发生这种情况
不需要此目录。
有没有一种方法可以避免使用不需要此目录的local
?
(关于Python 2.7)
答案 0 :(得分:7)
浏览文档和一些较旧的SO帖子时,我偶然发现了this的答案和官方的Release Notes。
在我的Ubuntu 16.04
和virtualenv 15.0.1
组合上,~/.local
文件夹包含所有与Python相关的库,文档和二进制文件。
我怀疑virtualenv试图“匹配”这种方法,以保持与在裸机上运行的脚本的兼容性,因为Python $PATH
在那里寻找与Python相关的模块,软件包等。< / p>
Python 2.7.12 (default, Dec 4 2017, 14:50:18)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print '\n'.join(sys.path)
/usr/lib/python2.7
/usr/lib/python2.7/plat-x86_64-linux-gnu
...
/home/<username>/.local/lib/python2.7/site-packages
...
/usr/local/lib/python2.7/dist-packages
/usr/lib/python2.7/dist-packages
如果我在virtualenv中运行相同的命令,则会在Python路径中获得两个目录。
Python 2.7.12 (default, Dec 4 2017, 14:50:18)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print '\n'.join(sys.path)
/home/<username>/python-venv-tests/lib/python2.7
/usr/lib/python2.7
...
/home/<username>/python-venv-tests/local/lib/python2.7/site-packages
/home/<username>/python-venv-tests/lib/python2.7/site-packages
...
所以,回答您的问题
.local
目录仅包含指向虚拟环境的“正确” /bin, /include, /lib
的符号链接,因此没有重复库的危险~/.local
与Ubuntu的兼容性而采取的措施$PATH
,但这不会对您的工作流产生任何影响(或者如果您打算将虚拟环境迁移到其他主机)。答案 1 :(得分:3)
在Ubuntu中,virtualenv模仿了计算机的安装,本地是其中的一部分。
如果您想在项目中忽略它,可以将其添加到#!/bin/bash
#getting the current hdfs percentage in numeric value
CURRENT=$(hdfs dfs -df -h/ | grep / | awk '{ print $8}' | sed 's/%//g')
#current hdfs space utilisation
DiskFile=$(hdfs dfs -df -h)
HdfsReport=$(hdfs dfsadmin -report)
Diskuse=$(hdfs dfs -du /user | sort -nr | head -10)
#To get results GB i have provided $(hdfs dfs -du -h /user | sort -r | head -10)
THRESHOLD=70
Critical=90
if [ "$CURRENT" -gt "$THRESHOLD" ] ; then
mail -s 'HDFS Usage Housekeeping required' @abc.com, @abc.com << EOF
HDFS usage in Cluster is above the threshold please run the clean-up scripts asap. Used: $CURRENT%
Current disk utilization report is
$DiskFile
Please find the Utilisation report of top ten users consuming the cluster
$Diskuse
EOF
fi
if [ "$CURRENT" -gt "$Critical" ] ; then
mail -s 'HDFS Admin Report' yy@abc.com, yyy@abc.com << EOF
HDFS usage in Cluster is above critical storage, please Find the Cluster report below
$HdfsReport
EOF
fi