Search code examples
linuxbashshellvirtualenvwrapper

mkproject: command not found in shell script


Problem

I have a problem creating a virtualenvwrapper project in a shell script. When I create a project in shell all is ok. But a want to create it in a shell script.

Please help me to solve this problem.

I tried to find the answer. But it seems that no one had a trouble with creating virtualenvwrapper project in a shell script.

My setup

I'm using Ubuntu 14.04. I have installed "virtualenvwrapper" package:

sudo pip install virtualenvwrapper

And wrote this lines into ~/.bashrc:

export WORKON_HOME=~/work/.envs
export PROJECT_HOME=~/work/projects
export VIRTUAL_ENV_DISABLE_PROMPT=
source /usr/local/bin/virtualenvwrapper.sh

activated bash profile with:

$ source ~/.bashrc

and created project dir:

$ mkdir -p $PROJECT_HOME

Additional info

When I run:

type mkproject

in terminal it returns me:

mkproject is a function
mkproject () 
{ 
    typeset -a in_args;
    typeset -a out_args;
    ...[and more lines after]
}

when this command executed from script it returns this:

./setup2.sh: line 2: type: mkproject: not found

Command

$ ls -l setup2.sh

returns:

-rwxrwxr-x 1 name name 49 марта 23 12:55 setup2.sh*

Creating project with shell script

After that I have created shell script (setup2.sh) with following lines:

#!/bin/bash
mkproject test_env

When I run this script by relative path:

$ ./setup2.sh

or aboslute path:

$ /home/name/env/setup2.sh

It says:

./setup2.sh: line 2: mkproject: command not found

Creating project in shell

But when I run command which creates a project in a terminal:

$ mkproject test_env

all works fine


Solution

  • There can be several causes for this, but I would first output $PATH inside your script and verify that it contains the directory where mkproject is supposed to be.

    You should also verify that mkproject is indeed an executable, and not an alias or function, because functions are not exported by default. For this, run in your console the command

    type mkproject