1

So I wrote some code in python that used the requests library. I am thinking of uploading the files onto github so other people can test out the file. Uploading the main is easy (just one .py) file, but how do I include the requests library?

Is there a way for me to also the requests library along with my .py file so they can immediately run the python file ? or should I tell them to also install requests through pip first?

6
  • you can install external libraries in a virtual environment and upload your environment folder. Commented Sep 24, 2014 at 14:51
  • interesting suggestion. Are there any guides on how to do that?? thanks! Commented Sep 24, 2014 at 15:03
  • guide of which topic? Commented Sep 24, 2014 at 15:05
  • I guess both install external libraries in a virtual environment and then uploading it Commented Sep 24, 2014 at 15:05
  • No, if you are familiar with virtual environment, pip, git you can do it. :) Commented Sep 24, 2014 at 15:07

1 Answer 1

1

I suppose you have a folder which you have initialized with git. Now form go to that directory and create a virtual environment by the command,

virtualenv env

activate the virtual environment by the command,

source env/bin/activate

Now install external libraries in it with pip.

pip install requests

Yor python file my.py will be in the same folder where you initialized git using git init. structure will be like,

project
|----env
|    |----bin
|    |----include
|    |----lib
|    |----local
|----my.py

Now you can push the contents of the projcet in your repository with necessary libraries installed in a virtual environment.

Sign up to request clarification or add additional context in comments.

6 Comments

Hi, not sure if I am doing this right or nt, but there is no env folder in my project folder. What I have is Include, lib, and Scripts
what process did you follow?
I first installed virtualenv using pip, then I call python -m virtualenv venv. In my newly created venv folder on my desktop, I see Include, Lib, and Scripts
create the virtual environment in your the folder that you are going to push in git. follow the instructions in my answer.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.