FS#48305 - [python-virtualenvwrapper] Creating an environment makes a bash script with invalid syntax.

Attached to Project: Community Packages
Opened by Joseph Fox-Rabinovitz (MadPhysicist) - Tuesday, 23 February 2016, 03:55 GMT
Last edited by Doug Newgard (Scimmia) - Sunday, 13 March 2016, 08:30 GMT
Task Type Bug Report
Category Packages
Status Closed
Assigned To Evangelos Foutras (foutrelis)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

I installed python-virtualenv and python-virtualenvwrapper as described in https://wiki.archlinux.org/index.php/Python/Virtualenv. The install went fine:

pacman -S python-virtualenv python-virtualenvwrapper

I added the following to the bottom of my .bashrc:

export PATH="${PATH}:${HOME}/bin"
export WORKON_HOME="${HOME}"/.virtualenvs
[ ! -d "${WORKON_HOME}" ] && mkdir -p "${WORKON_HOME}"

source /usr/bin/virtualenvwrapper.sh

The next time I sourced it, it created some scripts in ${WORKON_HOME}. When I tried to do

mkvirtualenv npt

I got the following error output:

Using base prefix '/usr'
New python executable in /home/joe/.virtualenvs/npt/bin/python3
Also creating executable in /home/joe/.virtualenvs/npt/bin/python
Installing setuptools, pip, wheel...done.
virtualenvwrapper.user_scripts creating /home/joe/.virtualenvs/npt/bin/predeactivate
virtualenvwrapper.user_scripts creating /home/joe/.virtualenvs/npt/bin/postdeactivate
virtualenvwrapper.user_scripts creating /home/joe/.virtualenvs/npt/bin/preactivate
virtualenvwrapper.user_scripts creating /home/joe/.virtualenvs/npt/bin/postactivate
virtualenvwrapper.user_scripts creating /home/joe/.virtualenvs/npt/bin/get_env_details
bash: deactivate: No such file or directory
bash: /home/joe/.virtualenvs/npt/bin/activate: line 4: syntax error near unexpected token `('
bash: /home/joe/.virtualenvs/npt/bin/activate: line 4: `deactivate () {'
bash: syntax error near unexpected token `('

Line 4 of `/home/joe/.virtualenvs/npt/bin/activate` contains the following:

deactivate () {

Similarly, line 69 contains the following:

pydoc () {

In both cases, the function definition is missing the `function` keyword.
This task depends upon

Closed by  Doug Newgard (Scimmia)
Sunday, 13 March 2016, 08:30 GMT
Reason for closing:  Not a bug
Comment by Doug Newgard (Scimmia) - Tuesday, 23 February 2016, 13:43 GMT
Are you using bash? The function keyword is not required.
Comment by Joseph Fox-Rabinovitz (MadPhysicist) - Tuesday, 23 February 2016, 13:45 GMT
Yes, I am using bash. I updated my system with `pacman -Syu` just before the install, so I have the latest version available. I have pretty much never used another shell on that machine. Just looked at the docs and yes, it appears that something else may be causing that error.
Comment by Joseph Fox-Rabinovitz (MadPhysicist) - Sunday, 13 March 2016, 05:26 GMT
I figured out what the issue was. I was using miniconda before this and had created a script called `miniconda.sh` which I dropped into `/etc/profile.d`. `miniconda.sh` did something like

CONDA_HOME=/opt/miniconda2
PATH="${CONDA_HOME}/bin:${PATH}"
alias deactivate='source deactivate'

Of course the last line was a stupud idea in hindsight, expecially since I did not get rid of the script once I uninstalled miniconda. The redefinition of `deactivate` was messing with `virtualenvwrapper`. This is not a real bug and there is nothing to fix, so I am requesting closure.

Loading...