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
    

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

  • 相关阅读:
    Python进阶-----类、对象的属性的增删改查
    SpringCloud(Finchley版) 服务注册与服务发现-Eureka原理深入
    SpringCloud项目之Eureka 配置 application.yml
    sql 获得各科最高分成绩和人数
    mysql主从同步
    Log4j.properties
    JDBC 配置 jdbc.properties
    Java 通过ant打包时给JS/Jsp/css等文件加上版本号 防止有缓存
    Ant 打包 build文件
    Java zip 压缩包下载excel文件
  • 原文地址:https://www.cnblogs.com/technicianafei/p/14581106.html
Copyright © 2011-2022 走看看