Issue
I want to make a virtual environment for a Flask application and I get this error when I try to activate it:
C:\Users\jessa\Desktop\travaux-pratiques\tp4-web-bbelzile\depart>python ./env/Scripts/activate
File "./env/Scripts/activate", line 4
deactivate (){
^
SyntaxError: invalid syntax
It's not the first time that I try to make an env but it is the first time that I get this error.
Solution
Here:
C:\...\depart>python ./env/Scripts/activate
You are trying to run the activation script as a Python script/file. That's not a Python script and should not be run with a Python interpreter.
As indicated in the virtual environment docs:
Once a virtual environment has been created, it can be “activated” using a script in the virtual environment’s binary directory. The invocation of the script is platform-specific (
<venv>
must be replaced by the path of the directory containing the virtual environment):Windows | cmd.exe | C:\> <venv>\Scripts\activate.bat | PowerShell | PS C:\> <venv>\Scripts\Activate.ps1
(I'm assuming you are activating it on Windows based on the path)
Answered By - Gino Mempin Answer Checked By - Mildred Charles (WPSolving Admin)