Mac在python3环境下安装virtualwrapper遇到的问题及解决方法

yipeiwu_com6年前Python基础

前言

我在使用mac安装virtualwrapper的时候遇到了问题,搞了好长时间,才弄好,在这里总结一下分享出来,供遇到相同的问题的朋友使用,少走些弯路。

问题说明:

Mac默认系统的python2,而我自己用的是brew安装的python3

下面是我安装过程中出现的问题

1. 安装virtualwrapper

打开终端,输入如下的命令

pip3 install virtualenv
pip3 install virtualenvwrapper

2. 在配置文件~/.bash_profile中添加代码

# Settings for virtualenvwrapper
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh

3. 让配置生效:

source ~/.bash_profile

这时,出现了如下问题:

/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/bin/python and that PATH is set properly. 这一句话来看,是环境指向了python2的路径,所以我们只需要将这个环境变量修改为python3的路径即可。

解决办法

打开配置文件 vim ~/.bash_profile 在配置文件中添加一行代码:

export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python3

让配置生效:

source ~/.bash_profile

再试一下,大功搞成!!!

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持【听图阁-专注于Python设计】。

相关文章

python使用opencv对图像mask处理的方法

python使用opencv对图像mask处理的方法

MASK图像掩膜处理 在图像操作中有时候会用到掩膜处理,如果使用遍历法掩膜图像ROI区域对于python来讲是很慢的,所以我们要找到一种比较好的算法来实现掩膜处理。 假设我们有一副图...

使用python实现BLAST

使用python实现BLAST

最近在自学python,又用python实现了一下BLAST。 这次更新了打分函数如下,空位罚分改为-5,但不区分gap open 和 gap extend。 ''''' @au...

python批量将excel内容进行翻译写入功能

由于小编初来乍到,有很多地方不是很到位,还请见谅,但是很实用的哦! 1.首先是需要进行文件的读写操作,需要获取文件路径,方式使用os.listdir(路径)进行批量查找文件。 fil...

Python中的random()方法的使用介绍

 random()方法返回一个随机浮点数r,使得0是小于或等于r 以及r小于1。 语法 以下是random()方法的语法: random ( ) 注意:此函数是无法直...

Python enumerate遍历数组示例应用

    其他语言中,比如C#,我们通常遍历数组是的方法是:for (int i = 0; i <&nbs...