那么,在这里查看有很多关于如何在Mac上正确安装virtualenvwrapper的问题。我真的尝试了所有这些,但无济于事。我注意到以前的问题不像我的电脑那样配置,所以这里是:
/Library/Frameworks/Python.framework/Versions/3.5/bin/python3
python3 get-pip.py
命令正确安装pip
,我认为sudo pip3 virtualenvwrapper
确保所有设置都按照~/.bash_profile
:
export WORKON_HOME=$HOME/.virtualenvs export PROJECT_HOME=$HOME/projects source /usr/local/bin/virtualenvwrapper.sh
然后,每当我打开一个新的终端时,我都明白了:
/usr/bin/python: No module named virtualenvwrapper virtualenvwrapper.sh: There was a problem running the initialization hooks. If Python could not import the module virtualenvwrapper.hook_loader, check that virtualenvwrapper has been installed for VIRTUALENVWRAPPER_PYTHON=/usr/bin/python and that PATH is set properly.
我尝试过其他问题的解决方案,但无济于事:
VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python3
VIRTUALENVWRAPPER_PYTHON="$(command \which python3)"
ln -fs /Library/Frameworks/Python.framework/Versions/3.5/bin/python3 /usr/local/bin/python3
alias python=/usr/local/bin/python3
好吧,期待任何像我这样配置的人看看我做错了什么。
答案 0 :(得分:9)
这是相当古老的,但发布这个是因为我从谷歌来到这里,最后想出了正确的道路。
export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_PYTHON=/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6
export PROJECT_HOME=$HOME/Devel
source /Library/Frameworks/Python.framework/Versions/3.6/bin/virtualenvwrapper.sh
你必须确保拥有实际的python可执行文件。只需在Finder中浏览到/ bin并查看其中的内容即可找到。
答案 1 :(得分:2)
嗯,经过大量努力,我决定在macOS Sierra中附带的Python 2.7上安装<?php
$strs = array();
while( $rowss = mysql_fetch_array( $result2, MYSQL_ASSOC ) ){
$strs[]=$rowss["ingredient"];
}
?>
<script>
<?php
echo "var strs=JSON.parse( " . json_encode( $strs ) . " );\n";
?>
for( var n in strs ){
var str = strs[ n ];
var str_array = str.split(',');
for( var i = 0; i < str_array.length; i++ ) {
str_array[i] = str_array[i].replace(/^\s*/, "").replace(/\s*$/, "");
var opt = document.createElement('option');
opt.innerHTML = str_array[i];
opt.value = str_array[i];
sel.appendChild(opt);
}
}
</script>
和pip
。
之后,我在virtualenvwrapper
上写下了这些行。也许这里有一些多余的东西,但它确实有效。
.bash_profile
之后,我从python.org安装了Python 3.5.2并创建了一个指向它的新环境,一切正常。
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/Documents/Projects/
ln -fs /Users/myusername/Library/Python/2.7/bin/virtualenvwrapper.sh /usr/local/bin/virtualenvwrapper.sh
ln -fs /Users/myusername/Library/Python/2.7/bin/virtualenv /usr/local/bin/virtualenv
source /usr/local/bin/virtualenvwrapper.sh