2

I am building a Python script for processing json data according to some criteria. Also I have built a custom module which consists of methods for retrieving json data and generation of json file which consist of processed data. But that module file is stored into S3 bucket and I need to import that module into my script so that I can invoke functions defined in module.

Please suggest me appropriate solution regarding importing python module from external URL

2
  • 2
    Why is the module on S3? Why not install it in your project? Commented Sep 2, 2015 at 11:45
  • 1
    or cleanly package it so you can deploy it with pip... Commented Sep 2, 2015 at 11:48

3 Answers 3

0

Package your module into your favorite extension (tarball, wheel, etc.) using setuptools and then you will be able to install it using pip as bruno by doing something like:

pip install --no-index --trusted-host s3_ip/host --find-links http://s3.com...
Sign up to request clarification or add additional context in comments.

Comments

0

Well, you could download the file using urllib2 and then import it, if the online module is all in one file:

from urllib2 import urlopen
r = urlopen('http://urlHere/fileHere')  
f = open('filenameToWrite', 'w')
f.write(r.read())
f.close()
import filenameWithout.PyInIt  

Comments

0

Please see my answer to question # 48905127 - believed to be the best solution I found so far and comes with detailed steps and code snippets ready for you to copy and use.

Comments

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.