博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
(坑集)virtualenvwrapper.sh: There was a problem running the initialization hooks. If Python could not
阅读量:4202 次
发布时间:2019-05-26

本文共 1491 字,大约阅读时间需要 4 分钟。

virtualenvwrapper配置报错

在安装好virtualenvwrapper之后,需要在~/.bashrc中配置,把vw的.sh文件添加进去,还可以选择修改虚拟环境默认保存的位置。
首先在编辑.bashrc之前,你需要知道virtualenvwrapper.sh文件的路径,使用下面的命令查找。

sudo find / -name virtualenvwrapper.sh

下面是我的查找结果

在这里插入图片描述
因为我是直接安装在我的用户路径下的,所以如果你是安装在根目录下,结果应该是/usr/local/bin/virtualenvwrapper.sh。

得知路径之后就可以在~/.bashrc文件中添加下面配置

export WORKON_HOME=$HOME/virtualenvs # 配置虚拟环境的保存位置 $HOME是用户的主目录source /home/God/.local/bin/virtualenvwrapper.sh # 配置virtualenvwrapper命令的脚本

第一条配置可以随你的喜爱去更改,但是第二条配置需要使用刚才获取路径,只有命令脚本路径正确才可在linux中直接使用virtualenvwrapper中的命令。

修改.bashrc文件后,需要重新加载.bashrc文件

source ~/.bashrc

重点!!!

如果你的环境是python3,重新加载后,可能会出现这样类似的错误

/usr/bin/python: No module named virtualenvwrappervirtualenvwrapper.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 forVIRTUALENVWRAPPER_PYTHON=/usr/bin/python and that PATH isset properly.

因为在virtualenvwrapper.sh中有如下代码

# Locate the global Python where virtualenvwrapper is installed.if [ "$VIRTUALENVWRAPPER_PYTHON" = "" ] then    VIRTUALENVWRAPPER_PYTHON="$(command \which python)"fi

脚本会默认使用python2环境,但是virtualenvwrapper装在了python3环境中,所以会有上面的报错。

解决办法:

直接将VIRTUALENVWRAPPER_PYTHON默认值修改为/usr/bin/python3即可

# Locate the global Python where virtualenvwrapper is installed.VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3if [ "$VIRTUALENVWRAPPER_PYTHON" = "" ] then    VIRTUALENVWRAPPER_PYTHON="$(command \which python)"fi

修改后,按照上面步骤,重新加载下virtualenvwrapper.sh即可解决问题。

转载地址:http://dnili.baihongyu.com/

你可能感兴趣的文章
JQuery 简介
查看>>
Java创建对象的方法
查看>>
Extjs自定义组件
查看>>
TreeGrid 异步加载节点
查看>>
Struts2 标签库讲解
查看>>
Google Web工具包 GWT
查看>>
材料与工程学科相关软件
查看>>
MPI的人怎么用仪器
查看>>
windows 下AdNDP 安装使用
查看>>
Project 2013项目管理教程(1):项目管理概述及预备
查看>>
ssh客户端后台运行
查看>>
哥去求职,才说了一句话考官就让我出去
查看>>
【React Native】把现代web科技带给移动开发者(一)
查看>>
【GoLang】Web工作方式
查看>>
Launch Sublime Text 3 from the command line
查看>>
【数据库之mysql】mysql的安装(一)
查看>>
【数据库之mysql】 mysql 入门教程(二)
查看>>
【HTML5/CSS/JS】A list of Font Awesome icons and their CSS content values(一)
查看>>
【HTML5/CSS/JS】<br>与<p>标签区别(二)
查看>>
【HTML5/CSS/JS】开发跨平台应用工具的选择(三)
查看>>