Why can’t I get `pip install lxml` to work within a virtualenv?

You probably already have lxml installed on your system, perhaps installed due to a system package. Thus, the first attempt (pip install lxml without an active virtualenv) doesn’t fail, but it also doesn’t install it; it really doesn’t do anything. In a virtualenv, by default, the system packages are ignored. Therefore, pip thinks that lxml … Read more

How to automatically activate virtualenvs when cd’ing into a directory

Add following in your .bashrc or .zshrc function cd() { builtin cd “$@” if [[ -z “$VIRTUAL_ENV” ]] ; then ## If env folder is found then activate the vitualenv if [[ -d ./.env ]] ; then source ./.env/bin/activate fi else ## check the current folder belong to earlier VIRTUAL_ENV folder # if yes then … Read more

How to set virtualenv for a crontab?

Is there something equivalent I could do in crontab to activate a virtualenv? This works well for me… ## call virtualenv python from crontab 0 9 * * * /path/to/virtenv/bin/python /path/to/your_cron_script.py I prefer using python directly from the virtualenv instead of hard-coding the virtualenv $PATH into the script’s shebang… or sourcing the venv activate

Python Virtualenv – No module named virtualenvwrapper.hook_loader

The issue was solved following the steps below: #switch the /usr/bin/python link to point to current python link cd /usr/bin sudo mv python python.bak sudo ln -s /Library/Frameworks/Python.framework/Versions/Current/bin/python python Re-arrange the export command in order that it is placed before the virtualenv commands in my .bash_profile file: PATH=/Library/Frameworks/Python.framework/Versions/2.7/bin:$PATH export PATH # needed for virtualenvwrapper export … Read more

Python – manually install package using virtualenv

I typically would extract the program to a temporary folder, then from that folder, run the setup.py using the direct path to the virtualenv python instance. eg if your virtualenv is in /home/username/virtualpy, use this (from your temporary folder) /home/username/virtualpy/bin/python setup.py install This should install it to your virtualenv site package folder.

bash: mkvirtualenv: command not found

Solution 1: For some reason, virtualenvwrapper.sh installed in /usr/bin/virtualenvwrapper.sh, instead of under /usr/local/bin. The following in my .bash_profile works… source “/usr/bin/virtualenvwrapper.sh” export WORKON_HOME=”/opt/virtual_env/” My install seems to work fine without sourcing virtualenvwrapper_bashrc Solution 2: Alternatively as mentioned below, you could leverage the chance that virtualenvwrapper.sh is already in your shell’s PATH and just issue a … Read more

virtualenvwrapper and Python 3

If you already have python3 installed as well virtualenvwrapper the only thing you would need to do to use python3 with the virtual environment is creating an environment using: which python3 #Output: /usr/bin/python3 mkvirtualenv –python=/usr/bin/python3 nameOfEnvironment Or, (at least on OSX using brew): mkvirtualenv –python=`which python3` nameOfEnvironment Start using the environment and you’ll see that … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)