zoukankan      html  css  js  c++  java
  • No module named virtualenvwrapper 虚拟环境报错

    No module named virtualenvwrapper 虚拟环境报错

    1. 安装虚拟环境命令
    sudo pip install virtualenv
    sudo pip install virtualenvwrapper
    
    # 1、创建目录用来存放虚拟环境
    mkdir $HOME/.virtualenvs    # $HOME代表家目录,用于保存虚拟环境产生的目录
    
    # 2、打开~/.bashrc文件,并添加如下:
    export WORKON_HOME=$HOME/.virtualenvs  # 导入虚拟环境保存的目录
    source /usr/local/bin/virtualenvwrapper.sh  # 添加命令的路径
    
    # 3、运行
    source ~/.bashrc  # 让命令生效
    

    接下来如果出现下列报错的话,是因为在~/.bashrc这个文件中没有设置python解释器的路径

    /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.
    

    需要插入如下代码

    export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
    export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv
    

    然后再运行命令

    source ~/.bashrc
    

    如果出现下面的输出

    virtualenvwrapper.user_scripts creating /home/ubuntu/.virtualenvs/initialize
    virtualenvwrapper.user_scripts creating /home/ubuntu/.virtualenvs/premkvirtualenv
    virtualenvwrapper.user_scripts creating /home/ubuntu/.virtualenvs/postmkvirtualenv
    virtualenvwrapper.user_scripts creating /home/ubuntu/.virtualenvs/prermvirtualenv
    virtualenvwrapper.user_scripts creating /home/ubuntu/.virtualenvs/postrmvirtualenv
    virtualenvwrapper.user_scripts creating /home/ubuntu/.virtualenvs/predeactivate
    virtualenvwrapper.user_scripts creating /home/ubuntu/.virtualenvs/postdeactivate
    virtualenvwrapper.user_scripts creating /home/ubuntu/.virtualenvs/preactivate
    virtualenvwrapper.user_scripts creating /home/ubuntu/.virtualenvs/postactivate
    virtualenvwrapper.user_scripts creating /home/ubuntu/.virtualenvs/get_env_details
    virtualenvwrapper.user_scripts creating /home/ubuntu/.virtualenvs/premkproject
    virtualenvwrapper.user_scripts creating /home/ubuntu/.virtualenvs/postmkproject
    

    表示虚拟环境的命令导入成功了,可以正常使用

  • 相关阅读:
    抽取幸运观众
    随机产生139开头的电话号码
    脚本同步服务器系统时间
    判断网页是否存活
    nginx 添加到环境变量中
    spring boot helloworld
    IDEA 2019.3.3 Maven配置
    Window IDEA ULTIMATE 2019.3.3 安装&配置
    centos 7 Jenkins版本升级
    window 10 vscode+vue配置
  • 原文地址:https://www.cnblogs.com/technicianafei/p/14581106.html
Copyright © 2011-2022 走看看