最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【貌似无需解决】Mac中active后virtualenv没有生效

Mac crifan 4138浏览 0评论

折腾:

【记录】安装Tensor Flow

后然后继续:

➜  youtubeSubtitle source /Users/crifan/dev/dev_root/tensorflow/bin/activate

结果并没有出现:

“上面的 source 命令应该将提示符改成了下面这样:

(tensorflow)$”

mac virtualenv activate not working

mac virtualenv source activate not working

mac virtualenv source activate not work

bash – Issue with activating virtualenv – Stack Overflow

Virtualenv · macOS Setup Guide

换了个终端,也还是不行:

python – How to activate virtualenv? – Stack Overflow

virtualenv – There is no activate when I am trying to run my virtual env – Stack Overflow

virtualenv active 没用

virtualenv active 不起效果

关于学习Flask过程中Python虚拟环境的激活问题? – 知乎

初学python者自学anaconda的正确姿势是什么?? – 知乎

Anacodna之conda与 virtualenv对比使用教程,创建虚拟环境 – Python – 伯乐在线

再去试了试,还是不行,去看看内容:

➜  dev_root source tensorflow/bin/activate

➜  dev_root cat tensorflow/bin/activate

# This file must be used with “source bin/activate” *from bash*

# you cannot run it directly

deactivate () {

    unset -f pydoc >/dev/null 2>&1

    # reset old environment variables

    # ! [ -z ${VAR+_} ] returns true if VAR is declared at all

    if ! [ -z “${_OLD_VIRTUAL_PATH+_}” ] ; then

        PATH=”$_OLD_VIRTUAL_PATH”

        export PATH

        unset _OLD_VIRTUAL_PATH

    fi

    if ! [ -z “${_OLD_VIRTUAL_PYTHONHOME+_}” ] ; then

        PYTHONHOME=”$_OLD_VIRTUAL_PYTHONHOME”

        export PYTHONHOME

        unset _OLD_VIRTUAL_PYTHONHOME

    fi

    # This should detect bash and zsh, which have a hash command that must

    # be called to get it to forget past commands.  Without forgetting

    # past commands the $PATH changes we made may not be respected

    if [ -n “${BASH-}” ] || [ -n “${ZSH_VERSION-}” ] ; then

        hash -r 2>/dev/null

    fi

    if ! [ -z “${_OLD_VIRTUAL_PS1+_}” ] ; then

        PS1=”$_OLD_VIRTUAL_PS1″

        export PS1

        unset _OLD_VIRTUAL_PS1

    fi

    unset VIRTUAL_ENV

    if [ ! “${1-}” = “nondestructive” ] ; then

    # Self destruct!

        unset -f deactivate

    fi

}

# unset irrelevant variables

deactivate nondestructive

VIRTUAL_ENV=”/Users/crifan/dev/dev_root/tensorflow”

export VIRTUAL_ENV

_OLD_VIRTUAL_PATH=”$PATH”

PATH=”$VIRTUAL_ENV/bin:$PATH”

export PATH

# unset PYTHONHOME if set

if ! [ -z “${PYTHONHOME+_}” ] ; then

    _OLD_VIRTUAL_PYTHONHOME=”$PYTHONHOME”

    unset PYTHONHOME

fi

if [ -z “${VIRTUAL_ENV_DISABLE_PROMPT-}” ] ; then

    _OLD_VIRTUAL_PS1=”$PS1″

    if [ “x” != x ] ; then

        PS1=”$PS1″

    else

        PS1=”(`basename \”$VIRTUAL_ENV\”`) $PS1″

    fi

    export PS1

fi

# Make sure to unalias pydoc if it’s already there

alias pydoc 2>/dev/null >/dev/null && unalias pydoc

pydoc () {

    python -m pydoc “$@”

}

# This should detect bash and zsh, which have a hash command that must

# be called to get it to forget past commands.  Without forgetting

# past commands the $PATH changes we made may not be respected

if [ -n “${BASH-}” ] || [ -n “${ZSH_VERSION-}” ] ; then

    hash -r 2>/dev/null

fi

➜  dev_root

所以去:

➜  dev_root cd tensorflow

➜  tensorflow source bin/activate

➜  tensorflow

结果还是不行。

virtualenv 激活 不起效果

新开了个终端,还是不行:

换个目录,还是不行:

➜  tensorflow virtualenv –system-site-packages /Users/crifan/dev/dev_root/virtualenv

New python executable in /Users/crifan/dev/dev_root/virtualenv/bin/python2.7

Also creating executable in /Users/crifan/dev/dev_root/virtualenv/bin/python

Installing setuptools, pip, wheel…done.

➜  tensorflow source ../virtualenv/bin/activate

virtualenv activate mac

再去试试,还是不行:

➜  dev_root cd tensorflow

➜  tensorflow ll

➜  tensorflow virtualenv venv

New python executable in /Users/crifan/dev/dev_root/tensorflow/venv/bin/python2.7

Also creating executable in /Users/crifan/dev/dev_root/tensorflow/venv/bin/python

Installing setuptools, pip, wheel…done.

➜  tensorflow source venv/bin/activate

virtualenv not work

python – Activating a virtual env not working – Stack Overflow

重启iTerm试试,问题依旧。

python – Active virtualenv is not working – Stack Overflow

Virtualenv’s `bin/activate` is Doing It Wrong

virtualenv

干脆重新卸载virtualenv再重装

结果卸载出错:

【已解决】mac中卸载virtualenv出错:Not uninstalling virtualenv at outside environment

➜  virtualenv pip install virtualenv

Collecting virtualenv

  Using cached virtualenv-15.1.0-py2.py3-none-any.whl

Installing collected packages: virtualenv

Successfully installed virtualenv-15.1.0

以为旧名字可能冲突,所以去重命名再去试试,还是不行:

➜  virtualenv ll

➜  virtualenv virtualenv –system-site-packages tensorflow

New python executable in /Users/crifan/dev/dev_root/virtualenv/tensorflow/bin/python2.7

Also creating executable in /Users/crifan/dev/dev_root/virtualenv/tensorflow/bin/python

Installing setuptools, pip, wheel…done.

➜  virtualenv ll

total 0

drwxr-xr-x  7 crifan  staff   224B  1 27 13:16 tensorflow

➜  virtualenv source tensorflow/bin/activate

➜  virtualenv source tensorflow/bin/activate

➜  virtualenv source tensorflow/bin/activate

➜  virtualenv virtualenv –system-site-packages tensorflow2

New python executable in /Users/crifan/dev/dev_root/virtualenv/tensorflow2/bin/python2.7

Also creating executable in /Users/crifan/dev/dev_root/virtualenv/tensorflow2/bin/python

Installing setuptools, pip, wheel…done.

➜  virtualenv source tensorflow2/bin/activate

➜  virtualenv source tensorflow2/bin/activate

教程:在 Mac OS X 上安装 TensorFlow

-》

TensorFlow-wiki/Installing TensorFlow on Mac OS X.md at master · TensorFlowNews/TensorFlow-wiki

或许本身已经生效了,但是看不出来?

毕竟:

activate后,是可以执行deactivate的,并且再次执行deactivate会提示找不到:

所以,暂时先假定已经正常激活了虚拟环境了

所以或许是无需解决?

转载请注明:在路上 » 【貌似无需解决】Mac中active后virtualenv没有生效

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
89 queries in 0.204 seconds, using 22.07MB memory