I have been through search and tried various alternatives without success and spent several days on it now – driving me mad.
Running on Red Hat Linux with Python 2.5.2
Began using most recent Virtualenv but could not activate it, I found somewhere suggesting needed earlier version so I have used Virtualenv 1.6.4 as that should work with Python 2.6.
It seems to install the virtual environment ok
[necrailk@server6 ~]$ python virtualenv-1.6.4/virtualenv.py virtual
New python executable in virtual/bin/python
Installing setuptools............done.
Installing pip...............done.
Environment looks ok
[necrailk@server6 ~]$ cd virtual
[necrailk@server6 ~/virtual]$ dir
bin include lib
You forgot to do source bin/activate where source is a executable name.
Struck me first few times as well, easy to think that manual is telling “execute this from root of the environment folder”.
Go to the project directory. In my case microblog is the flask project directory and under microblog directory there should be app and venv folders. then run the below command, This is one worked for me in Ubuntu.
The problem there is the /bin/. command. That’s really weird, since . should always be a link to the directory it’s in. (Honestly, unless . is a strange alias or function, I don’t even see how it’s possible.) It’s also a little unusual that your shell doesn’t have a .builtin for source.
One quick fix would be to just run the virtualenv in a different shell. (An obvious second advantage being that instead of having to deactivate you can just exit.)
/bin/bash --rcfile bin/activate
If your shell supports it, you may also have the nonstandard source command, which should do the same thing as ., but may not exist. (All said, you should try to figure out why your environment is strange or it will cause you pain again in the future.)
By the way, you didn’t need to chmod +x those files. Files only need to be executable if you want to execute them directly. In this case you’re trying to launch them from ., so they don’t need it.
I had trouble getting running source /bin/activate then I realized I was using tcsh as my terminal shell instead of bash. once I switched I was able to activate venv.
Probably a little late to post my answer here but still I’ll post, it might benefit someone though,
I had faced the same problem,
The main reason being that I created the virtualenv as a “root” user
But later was trying to activate it using another user.
chmod won’t work as you’re not the owner of the file, hence the alternative is to use chown (to change the ownership)
For e.g. :
If you have your virtualenv created at /home/abc/ENV
Then CD to /home/abc
and run the command : chown -Rv[user-to-whom-you want-change-ownership] [folder/filename whose ownership needs to be changed]
In this example the commands would be : chown -Rv abc ENV
After the ownership is successfully changed you can simply run source /ENV/bin/./activate and your should be able to activate the virtualenv correctly.
1- open powershell and navigate to your application folder
2- enter your virtualenv folder ex : cd .\venv\Scripts\
3- active virtualenv by type .\activate