Badrush
Badrush

Reputation: 1287

How to add urllib.request to Heroku requirements.txt file?

My python code uses:

import traceback
import datetime
import time
import praw  # We use version 3.6.1
import string
import urllib.request 
import json  

and when deploying my requirements.txt (in it's entirety) is:

praw==3.6.1
yahoo-finance==1.4.0

As I try to deploy to Heroku I get errors such as urllib.request cannot be found... so I tried adding urllib.request to my requirements but I still get build errors saying

Could not find a version that satisfies the requirement urllib.request No matching distribution found for urllib.request

So how can I resolve this problem using Heroku?


Update: Instead of using urllib I ended up using the requests library.

My python (.py) code now uses:

 import traceback
 import datetime
 import time
 import praw  # We use version 3.6.1
 import string
 import requests
 import json

My requirements.txt file is: praw==3.6.1 requests==2.13.0

That was all that was required to get this requests library to load. I could not find a version number for urllib so I gave up on trying to add it to my requirements.txt and used this other library instead.

Upvotes: 1

Views: 3724

Answers (1)

Abhishek Vijayan
Abhishek Vijayan

Reputation: 753

urllib.request isn't the library, urllib is.

So even if you did from urllib import request it would work. Add 'urllib' to your requirements.txt

Upvotes: 3

Related Questions