29

1) I installed virtualenv using pip.
2) I ran the command virtualenv venv
3) Then I ran source venv/bin/activate but it says that there is no such file or directory.

When I cd into venv/bin I find 3 things - python, python 2.7, and python 3.5. Does anyone know the problem?

Thomas
  • 5,810
  • 7
  • 40
  • 48
Aaron Cheung
  • 311
  • 1
  • 4
  • 6
  • Just to check: what OS are you running this on? (Windows virtualenv, at least the one in front of me, puts activate in the scripts directory but then again, it also puts python in there vs bin) (Also, what other directories does venv have?) – Foon Jan 17 '17 at 01:53
  • I'm running it on mac osx. Venv also has include and lib. I feel like I downloaded too many versions of python now its screwing everything up. – Aaron Cheung Jan 18 '17 at 21:08
  • Hmm... I'm not used to virtualenv dropping down both python 2.7 and 3.5 as the result of running the command once... can you run virtualenv new-venv-18-Jan (or some other name that you've absolutely never used before), and include all the output you get from running that command? (Assuming you still don't get activate in the new virtualenv) – Foon Jan 18 '17 at 21:40
  • Its says: New python executable in... Installing setuptools, pip, wheel... Complete output from command... ImportError: dlopen ... Symbol not found ... Expected in: flat namespace ...Installing setuptools, pip, wheel...done. setuptools pip wheel failed with error code 1 Thats pretty much a summary of what it says – Aaron Cheung Jan 18 '17 at 23:33
  • So you ran `sudo pip install virtualenv` on your system Python? You really aren't giving us much help here ... – holdenweb Jan 19 '17 at 17:23
  • For some weird reason the `activate` files were created without the execute file privileges (664 to be precise). Changing the permissions didn't help though. – shad0w_wa1k3r Oct 15 '17 at 14:56
  • 3
    @AshishNitinPatil This is intentional. You shouldn't execute `activate`, but source it e.g. "source activate" or ". activate" (note space) – ivan_onys Feb 02 '18 at 13:16

7 Answers7

35

i have had the same problem. and what i did is just run the command virtualenv env again. And then more files were generated under directory env/bin, including the activate file. it's so weird.

crmpicco
  • 16,605
  • 26
  • 134
  • 210
jiaqi jiang
  • 451
  • 3
  • 2
  • 3
    This works. Slightly disconcerting that we don't know why. Not all the scripts were actually present in the bin directory. – Danny Staple Jul 11 '18 at 10:15
  • You might have moved the env folder after creating it the first time. – Victor Yan Jul 23 '18 at 03:10
  • The exact same thing occurred to me. Running `virtualenv venv` twice solved the problem. Never happened to me before. – Marcello Romani Jan 17 '21 at 01:09
  • I followed this advice and re-run the `virtualenv env` command. BUT interestingly my terminal prompted: **The virtual environment was not created successfully because ensurepip is not available. On Debian/Ubuntu systems, you need to install the python3-venv package using the following command. apt install python3.10-venv** which didn't yell these initially. I installed the package and it works like a charm. hope this might help someone. OS: ubuntu 22.04 pyhton3: v3.10.4 – Bek Sep 13 '22 at 12:35
7

I solved the similar problem running python3.7 -m venv venv, you can change for your version of python that is installed in your enviroment.

6

According to Python doc, the installation step is

$ python3 -m pip install --user virtualenv

$ python3 -m venv env

The last command gives a warning message,

The virtual environment was not created successfully because ensurepip is not
available.  On Debian/Ubuntu systems, you need to install the python3-venv
package using the following command.

    apt-get install python3-venv

You may need to use sudo with that command.  After installing the python3-venv
package, recreate your virtual environment.
$ sudo apt-get install python3-venv

Now, activate is available.

WhaSukGO
  • 575
  • 7
  • 17
1

I solved a similar problem by naming it venv2 when I ran virtualenv. I already had a virtual environment named venv for another project. This allowed me to proceed.

Steve Scott
  • 1,441
  • 3
  • 20
  • 30
1

I experienced this problem when using the --upgrade option. Removed the option, and all ran as expected.

0

I double it is caused by some networking issue, I run it twice to get 'activate' script installed. Maybe first it can't connect to some source so it just abort installation.

0

I had this happen on rasbian when I hadn't installed python3-pip before creating the venv.

Dustin Wyatt
  • 4,046
  • 5
  • 31
  • 60