26

I am trying to activate my Virtual Python Environment to use with Pylons but I think I am executing the commands wrong.

jem@jem-laptop:~$ source env/bin/activate
bash: env/bin/activate: No such file or directory

What am I doing wrong? How should I do it right?

8 Answers8

30

I realize I had to do

jem@jem-laptop:~$ ls
Desktop    examples.desktop  Public           shortener.rb
Documents  Mac4Lin_v1.0      ruby-1.9.1-p378  Templates
Downloads  Music             rubygems-1.3.7   Videos
Dropbox    Pictures          setcolors.vim    virtualenv.py

And here we see virtualenv.py. From here I just had to

jem@jem-laptop:~$ virtualenv ENV
New python executable in ENV/bin/python
Installing setuptools............done.

And then

jem@jem-laptop:~$ source ENV/bin/activate
(ENV)jem@jem-laptop:~$ deactivate
jem@jem-laptop:~$ 

Solved :)

  • On Unix-like systems the command `virtualenv` will not execute the file `virtualenv.py` - at least not directly. --- Anyway I would be interested where did the file `~/virtualenv.py` come from. – pabouk - Ukraine stay strong Mar 31 '21 at 08:06
7

I usually do it this way:

$ cd the_project_dir
$ . bin/activate
(the_project)$ _

I need to be in the project directory anyway to go on with the work. Obviously the_project_dir is the name of a directory where you have created a virtualenv.

9000
  • 39,899
  • 9
  • 66
  • 104
6

In 2.7 version I used this command:

$ cd project_name
$ virtualenv venv --distribute
$ source venv/Scripts/activate
(venv)
Cyclotron3x3
  • 2,188
  • 23
  • 40
1

I would recommend using virtualenvwrapper. It makes working with virtualenv a lot simpler, especially if you have more than one virtualenv.

Ben
  • 10,931
  • 9
  • 38
  • 47
1

Simple fix:

$ virtualenv env
$ cd env/Scripts/
$ . activate
0

On FreeBSD I solved this doing following:

# ls mypienv
# mypienv/bin/activate
mypienv/bin/activate: Permission denied.
# chmod +x mypienv/bin/activate
# mypienv/bin/activate
Missing '}'.

And you see that script not working but:

# ls mypienv/bin/
activate        activate.fish       easy_install-2.7    pip2.7          python2
activate_this.py    activate.ps1        pip         python          python2.7
activate.csh        easy_install        pip2            python-config       wheel

Finaly:

# python mypienv/bin/activate_this.py

And it worked! P.S. I am new with python python verions 2.7

Archil Labadze
  • 4,049
  • 4
  • 25
  • 42
0

env/Scripts/activate worked for me.

0range
  • 2,088
  • 1
  • 24
  • 32
Yemi159
  • 1
  • 1
  • 1
    Welcome to Stackoverflow. Very short answers are usually discouraged. Please consider adding more information. E.g., what exactly did you do with this file? `source env/Scripts/activate`? Something else? What system are you on? Any additional information that could help others? – 0range Aug 14 '20 at 17:41
0

For Windows, the following worked for me:

C:\.virtualenvs\env\Scripts>activate.bat

Deneb
  • 981
  • 2
  • 9
  • 25