0
votes

I have already installed pipenv using,
pip install pipenv on the directory which was installed successfully. But

pipenv install Django==2.1 does not seem to work. In fact, no command is getting executed using pipenv.

pip install pipenv

Collecting pipenv Downloading https://files.pythonhosted.org/packages/13/b4/3ffa55f77161cff9a5220f162670f7c5eb00df52e00939e203f601b0f579/pipenv-2018.11.26-py3-none-any.whl (5.2MB) 100% |████████████████████████████████| 5.2MB 5.5MB/s Requirement already satisfied: setuptools>=36.2.1 in /usr/local/lib/python3.6/dist-packages (from pipenv) (40.9.0) Collecting virtualenv-clone>=0.2.5 (from pipenv) Downloading https://files.pythonhosted.org/packages/ba/f8/50c2b7dbc99e05fce5e5b9d9a31f37c988c99acd4e8dedd720b7b8d4011d/virtualenv_clone-0.5.3-py2.py3-none-any.whl Requirement already satisfied: certifi in /usr/local/lib/python3.6/dist-packages (from pipenv) (2019.3.9) Requirement already satisfied: pip>=9.0.1 in /usr/local/lib/python3.6/dist-packages (from pipenv) (19.0.3) Collecting virtualenv (from pipenv) Downloading https://files.pythonhosted.org/packages/33/5d/314c760d4204f64e4a968275182b7751bd5c3249094757b39ba987dcfb5a/virtualenv-16.4.3-py2.py3-none-any.whl (2.0MB) 100% |████████████████████████████████| 2.0MB 17.1MB/s Installing collected packages: virtualenv-clone, virtualenv, pipenv Successfully installed pipenv-2018.11.26 virtualenv-16.4.3 virtualenv-clone-0.5.3

pipenv install Django==2.1

File "", line 1 pipenv install Django==2.1 ^ SyntaxError: invalid syntax

*

Anything on Google Colab suggestions would be very helpful!

*

1

1 Answers

0
votes

pip is a shell command. I assume Google Colab has made pip available as a special command(*) (without the % syntax), but that doesn't mean any other shell command works as such. That is why you get a SyntaxError: it is not recognised as normal Python syntax.

You can work around it by using !pipenv install 'Django==2.1' (the single quotes may not be necessary, but the exclamation work is).

I doubt, however, that you really need a virtual environment in the first place. This is not on your regular machine, where you may want to keep dependencies apart. Instead, just start a new notebook for a new project, and install Django as normal: pip install Django. I wouldn't bother with pipenv and virtual environments inside notebooks. There doesn't seem to be any use for it.


(*) Try, for example, pip?, and note the help lists its usage with the %pip syntax. I assume that, if it's not ambiguous, Colab will use %pip when called as pip. The same works for, for example, ls instead of %ls.