Search code examples
pythongithubvisual-studio-codepython-importvirtual-environment

How to handle imports for a shared project using GitHub using Visual Studio Code


I am looking for a way to setup a GitHub repo in a way that allows someone to clone it and then immediately run the code without needing to setup a virtual environment and then pip install all of the needed packages.

Perhaps I am off base and it is the case that they must install these packages and they can somehow be auto imported, but I'm not sure how that is done.

Or perhaps you can add the virtual environment folder as another folder in the repo, but I feel like you would still have to pip install in that case. (I'm not too familiar with virtual environments.)

I don't want to mess up the project, so I have not messed around with this too much.

Any help would be much appreciated!


Solution

  • Actually, you can create a requirements.txt file for the environment, then anyone (or any build server) that receives a copy of the project needs only to run the

     pip install -r requirements.txt 
    

    command to reinstall the packages on which the app depends within the active environment.

    Hope this gives you some inspiration. Detailed steps please view this tutorial: Create a requirements.txt file for the environment