virtualenv activation doesn't work

Forget about virtualenv, use the brand new Pipenv which is recommended by Python.org


Pipenv automatically creates and manages a virtualenv for your projects, as well as adds/removes packages from your Pipfile (more about this below) as you install/uninstall packages.


First install pipenv using:

$ pip install pipenv

Then, for installing project specific packages, first create your project folder and then install all necessary packages for your project like:

$ mkdir myproject
$ cd myproject

# install `requests` library
$ pipenv install requests

# install more libraries required for your project
$ pipenv install mysql-connector
$ pipenv install numpy

This will create two files, namely Pipfile and Pipfile.lock. You can find the list of all installed packages for the current project in the file Pipfile while Pipfile.lock has info on hashes like sha256 for all the installed packages and their dependencies.


Once you're done with the installation of all necessary packages for your project, then do:

$ pipenv shell

which will launch a subshell in virtual environment. (This does the similar job of source /your/virtualenv/activate)

Then you can start coding.. For example, you can first test whether installed packages are working fine by launching a Python shell and import the packages like below:

$ python
>>> import requests
# ....

To exit out of the (virtualenv) shell, simply do:

$ exit

Now, you're out of the virtual environment created by pipenv

Read more about it installing packages for your project @ pipenv.kennethreitz.org