Computational Social Science Post

Tips on R, Netlogo, and Python

Tips for VSCode

 Posted on Mar.18, 2023

Select Python Virtual Environments

Ctrl + Shift + p
Then, find Python : Select Interpreter
After selecting the environment, VScode will automatically choose it for python coding.

Create a Python Virtual Environment

  1. Create a Project folder
  2. In the Project, Open Terminal. If a virtual environment is running, Stop it with conda deactivate
  3. Create a virtual environment named "pyenv" python -m venv pyenv
  4. VScode will show it noticed a new virtual environment, and you can find pyenv folder in the Project Explorer
  5. Activate the environment : Type pyenv\Scripts\activate.bat. You can find it in the environment folder
  6. Make a requirement.txt file for installing requirement libraries. Just list library names and versions. ex) flask==1.0.0 request math stats gunicorn>=1.1.2,<2.0
  7. Then pip install -r requirement.txt
  8. Create a Jupyter file, test.ipynb. Then, use it.