28

I installed python environment by means of commands:

SYS_INSTALL="apt-get install -y"
PIP_INSTALL="pip install"

# Be sure to install setuptools before pip to properly replace easy_install.
$SYS_INSTALL git 
$SYS_INSTALL python-dev
$SYS_INSTALL python-setuptools
$SYS_INSTALL python-pip
$PIP_INSTALL virtualenv

also was able to create new virtual environment:

virtualenv .env

However, after running a command like:

. .env/bin/activate

I got

-bash: .env/bin/activate: No such file or directory

After reviewing folder .env/bin I found only one python file. Whole list of files here:

.env/lib:
python2.7

.env/include:
python2.7

.env/bin:
python

What is the issue here?

SOLUTION add --always-copy

virtualenv .env --always-copy

SpanishBoy
  • 2,105
  • 6
  • 28
  • 51
  • this has solved my issue : venv/bin/activate: No such file or directory as setup was not building bin directory – Prashant Feb 12 '19 at 09:10
  • This question is tagged with Ubuntu, but if you're on Windows see https://stackoverflow.com/questions/13206990/virtualenv-env-not-creating-bin-directory-in-windows-7 – mic Sep 19 '19 at 21:28

11 Answers11

38

For me it works when I do these steps:

  • Go to the directory/folder that you want

  • run virtualenv .env

  • then run source .env/bin/activate

Alex
  • 1,194
  • 1
  • 12
  • 20
13

The accepted answer is incomplete! The suggested code left out your error, but didn't comment on it.

The command . .env/bin/activate would indeed do the same as source on the file activate in the folder .env/bin. In fact, apparently the command "source" is an alias for the command ".", and not the other way around. Note that . here has a space after it, and used differently from the . discussed below (which makes files and folders hidden).

What I notice is that you are calling your folder .env, which is not standard practice. Files and folders preceded by . are made "hidden" by Mac OS X. Standard practice is to call a virtual environment directory env or venv, and to call the virtual environment specification file .env.

So, if your spec file is called .env and your virtual environment directory is called env, you can run either

source env/bin/activate or . env/bin/activate.

Zach Siegel
  • 330
  • 2
  • 9
12

I had the same issue and the following steps resolved it:

$mkdir annotateNLP
$cd annotateNLP
$python -m venv env
$source env/Scripts/activate
Laurel
  • 5,965
  • 14
  • 31
  • 57
Ruby
  • 161
  • 1
  • 2
7

Try these commands in the terminal:

$ mkdir djangoapp
$ cd djangoapp
$ python3 -m venv myvenv
$ source myvenv/bin/activate

You can't go straight into activate command without first creating your virtual environment.

Jules_ewls
  • 117
  • 1
  • 9
4

you forgot to include source before activating command is
source env/bin/activate

this question is similar to your's virtualenv is not compatible with this system or executable where it creates virtualenv but,python file instead of activate in bin

Community
  • 1
  • 1
shivsn
  • 7,680
  • 1
  • 26
  • 33
  • 1
    I believe issue here `.env/bin/activate: No such file or directory`. I don't have this file after running command `virtualenv .env` – SpanishBoy May 10 '16 at 12:12
  • try creating the file name without dot like virtualenv env – shivsn May 10 '16 at 12:24
  • try creating virtualenv with sudo or in root it works good or take a look at this link http://stackoverflow.com/questions/21686626/virtualenv-is-not-compatible-with-this-system-or-executable – shivsn May 10 '16 at 12:41
3

After going to your virtual environment folder .\Scripts\activate.

Abhishek Pratap Singh
  • 613
  • 3
  • 11
  • 18
1

I was facing this same issue. I uninstalled the virtualenv in Ubuntu and then I installed it again. After this nonsense, it works and now I am able to activate my virtualenv through -$source py3/bin/activate.

Asmath
  • 41
  • 2
1

In my case, I need to install

sudo apt-get install python3-venv

ebuzz168
  • 1,134
  • 2
  • 17
  • 39
1
$ virtualenv env
$ cd env/Scripts/
$ . activate
Laurel
  • 5,965
  • 14
  • 31
  • 57
Mutegi E
  • 11
  • 2
0

If installed venv on a Windows machine, run this command (assuming you are in the working directory that has your venv folder):

  • In bash terminal: source venv/Scripts/activate
  • In cmd terminal: venv\Scripts\activate

where venv is the folder name for your virtual environment

0

For windows using git bash, run the below command:-

source env\Scripts\activate
Mehadi Hassan
  • 1,160
  • 1
  • 13
  • 33