Skip to content

Instantly share code, notes, and snippets.

@hminnovation
Created February 16, 2017 15:08
Show Gist options
  • Save hminnovation/9a2f429caff5c091d5429666fa080403 to your computer and use it in GitHub Desktop.
Save hminnovation/9a2f429caff5c091d5429666fa080403 to your computer and use it in GitHub Desktop.
ZSH Virtualenv and Virtualenvwrapper setup

### Installing global Python & Pip Use Brew brew install python

That'll install both Python, PIP and setuptools. If for some reason it didn't install PIP you can do via

curl https://bootstrap.pypa.io/get-pip.py > get-pip.py
sudo python get-pip.py

c/f MacOSX setup gitbook

(Side note that you should install multiple versions of Python via Pyenv rather than Brew to avoid any bad Python conflicts)

Installing Virtualenv & Virtualenvwrapper

pip install virtualenv virtualenvwrapper

You'll need to tell ZSH where virtualenvs need to be put

In ~/.zshrc add

# Virtualenvwrapper things
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/Devel
source /usr/local/bin/virtualenvwrapper.sh

Showing the virtualenv name

By default the ZSH virtualenv plugin hides the virtualenv name. I've no idea why...

nano ~/.oh-my-zsh/plugins/virtualenv/virtualenv.plugin.zsh

Within that file you'll see

# disables prompt mangling in virtual_env/bin/activate
export VIRTUAL_ENV_DISABLE_PROMPT=1

Hash out export VIRTUAL_ENV_DISABLE_PROMPT=1 and reload ZSH.

Test that all working by doing something like

~ mkvirtualenv test2

You should see

New python executable in /Users/edd/.virtualenvs/test2/bin/python2.7
Also creating executable in /Users/edd/.virtualenvs/test2/bin/python
Installing setuptools, pip, wheel...done.
virtualenvwrapper.user_scripts creating /Users/edd/.virtualenvs/test2/bin/predeactivate
virtualenvwrapper.user_scripts creating /Users/edd/.virtualenvs/test2/bin/postdeactivate
virtualenvwrapper.user_scripts creating /Users/edd/.virtualenvs/test2/bin/preactivate
virtualenvwrapper.user_scripts creating /Users/edd/.virtualenvs/test2/bin/postactivate
virtualenvwrapper.user_scripts creating /Users/edd/.virtualenvs/test2/bin/get_env_details
(test2) ➜  ~ pip install something_awesome_inside_my_obvious_virtualenv 
@AbiruzzamanMolla
Copy link

not getting something like this '(test2) ➜ ~ pip install something_awesome_inside_my_obvious_virtualenv'

Ubuntu 17.10

@sreeuma87
Copy link

You got error message while installing OPENCV

pi@:/ $ source ~/.profile
/usr/bin/python2.7: 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/python2.7 and that PATH is
set properly.

It ll solve ur problem..

Procedure is
$ sudo pip3 install virtualenvwrapper

pi@:/ $ ls /usr/bin/python*
/usr/bin/python /usr/bin/python3 /usr/bin/python3-config
/usr/bin/python2 /usr/bin/python3.5 /usr/bin/python3m
/usr/bin/python2.7 /usr/bin/python3.5-config /usr/bin/python3m-config
/usr/bin/python2.7-config /usr/bin/python3.5m /usr/bin/python-config
/usr/bin/python2-config /usr/bin/python3.5m-config

pi@:~ $ cd /usr/local/bin
pi@:/usr/local/bin $ ls
dronekit-sitl mavgpslock.py mavsummarize.py
futurize mavgpslock.pyc mavsummarize.pyc
magfit_delta.py mavgraph.py mavtogpx.py
magfit_delta.pyc mavgraph.pyc mavtogpx.pyc
magfit_gps.py mavkml.py mavtomfile.py
magfit_gps.pyc mavkml.pyc mavtomfile.pyc
magfit_motors.py mavlogdump.py mp_slipmap.py
magfit_motors.pyc mavlogdump.pyc mp_slipmap.pyc
magfit.py mavloss.py mp_tile.py
magfit.pyc mavloss.pyc mp_tile.pyc
MAVExplorer.py mavmission.py MPU6KSearch.py
MAVExplorer.pyc mavmission.pyc MPU6KSearch.pyc
mavextract.py mavparmdiff.py pasteurize
mavextract.pyc mavparmdiff.pyc pbr
mavfft.py mavparms.py pip
mavfft.pyc mavparms.pyc pip2
mavflightmodes.py mavplayback.py pip2.7
mavflightmodes.pyc mavplayback.pyc pip3
mavflighttime.py mavproxy.py pip3.5
mavflighttime.pyc mavproxy.pyc virtualenv
mavflightview.py mavsearch.py virtualenv-clone
mavflightview.pyc mavsearch.pyc virtualenvwrapper_lazy.sh
mavgen.py mavsigloss.py virtualenvwrapper.sh
mavgen.pyc mavsigloss.pyc

pi@:/ $ nano ~/.profile
Add the following line at the end of the line

export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/Devel
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv
source /usr/local/bin/virtualenvwrapper.sh

pi@:/ $ source ~/.profile
Its Working..

virtualenvwrapper.user_scripts creating /home/pi/.virtualenvs/premkproject
virtualenvwrapper.user_scripts creating /home/pi/.virtualenvs/postmkproject
virtualenvwrapper.user_scripts creating /home/pi/.virtualenvs/initialize
virtualenvwrapper.user_scripts creating /home/pi/.virtualenvs/premkvirtualenv
virtualenvwrapper.user_scripts creating /home/pi/.virtualenvs/postmkvirtualenv
virtualenvwrapper.user_scripts creating /home/pi/.virtualenvs/prermvirtualenv
virtualenvwrapper.user_scripts creating /home/pi/.virtualenvs/postrmvirtualenv
virtualenvwrapper.user_scripts creating /home/pi/.virtualenvs/predeactivate
virtualenvwrapper.user_scripts creating /home/pi/.virtualenvs/postdeactivate
virtualenvwrapper.user_scripts creating /home/pi/.virtualenvs/preactivate
virtualenvwrapper.user_scripts creating /home/pi/.virtualenvs/postactivate
virtualenvwrapper.user_scripts creating /home/pi/.virtualenvs/get_env_details
pi@:/ $

@icehongssii
Copy link

error1

  • 이미지 감싸고 있는 태그의 문제인 줄 알았으나 <iframe>으로 감싸도 안됨
  • StackOverflow 확인해보니
    <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests" /> OR
    <meta http-equiv="Content-Security-Policy" content="block-all-mixed-content" />
    Paste it in <head>...</head> tags.
    위의 메타 태그 둘 중 하나를 헤드태그에 넣으면 된다고한다.
    The HTTP Content-Security-Policy (CSP) block-all-mixed-content directive prevents loading any assets using HTTP when the page is loaded using HTTPS.
    All mixed content resource requests are blocked, including both active and passive mixed content. This also applies to
    <<iframe/>
    documents, ensuring the entire page is mixed content free.
    The upgrade-insecure-requests directive is evaluated before block-all-mixed-content and If the former is set, the latter is effectively a no-op. It is recommended to set one directive or the other – not both.

@Prady96
Copy link

Prady96 commented Dec 25, 2018

Thanks man but for me it shows on the right side
screenshot 2018-12-25 at 1 43 32 pm

@fogx
Copy link

fogx commented Sep 18, 2019

hi, i think the best fix to
/usr/bin/python: No module named virtualenvwrapper virtualenvwrapper.sh: There was a problem running the initialization hooks.
is:
update-alternatives --install /usr/bin/python python /usr/bin/python3 10
from: https://stackoverflow.com/a/50331137/6825464

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment