简体   繁体   中英

bash_profile configure confusion

I am trying to install Python virtual environment using STEP:5 in this link Install OpenCV 3 on macOS with Homebrew (the easy way)

I am having trouble in configuring this file properly

$ nano ~/.bash_profile

Only editing the bash_profile like show

# Virtualenv/VirtualenvWrapper
source /usr/local/bin/virtualenvwrapper.sh

Is not allowing me to goto next step

I got this Warning mkvirtualenv: command not found

So altered it using help with this techstricks.com/mkvirtualenv-command-not-found-virtualenvwrapper/

Found this link on how to virtualenwrapper virtualenvwrapper.readthedocs.io/en/latest/install.html#python-interpreter-virtualenv-and-path

My bash_profile contains

    #Homebrew
export PATH=/usr/local/bin:$PATH

export WORKON_HOME=$HOME/.virtualenvs

# Virtualenv/VirtualenvWrapper
source /usr/local/bin/virtualenvwrapper.sh
export PROJECT_HOME=$HOME/Devel
export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python
export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv
export VIRTUALENVWRAPPER_VIRTUALENV_ARGS='--no-site-packages'

When I try to $ source ~/.bash_profile

I'm getting this

-bash: /usr/local/bin/python: No such file or directory
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/local/bin/python and that PATH is
set properly.

How do I fix this???????

I finally got it working.

I installed Virtualenv and Wrapper separatley

pip install virtualenv

Might help someone in future.


I installed Virtual Enviornment Wrapper using

pip install --user virtualenvwrapper

Link

virtualenvwrapper.readthedocs.io/en/latest/install.html#python-interpreter-virtualenv-and-path

Content of my bash_profile file

Homebrew

export PATH=/usr/local/bin:$PATH

#export WORKON_HOME=$HOME/.virtualenvs

# Virtualenv/VirtualenvWrapper source /usr/local/bin/virtualenvwrapper.sh #export PROJECT_HOME=$HOME/Devel #export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python #export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv #export VIRTUALENVWRAPPER_VIRTUALENV_ARGS='--no-site-packages'

Content of my bashrc file

export WORKON_HOME=$HOME/.virtualenvs

export PROJECT_HOME=$HOME/projects

source /usr/local/bin/virtualenvwrapper.sh

I had the same exact issue, but the way I got around it was different than /u/Santhosh DC. Following the breaking changes in Homebrew sometime in the last two months, I had to change: VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python to VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python2 .

Hope this helps someone.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM