can someone help me?
Let me explain myself better. I have this folder structure:
praw-test
jobs
__init__.py
redisJob.py
main.py
and if I run directly python jobs\redisJob.py
it works just fine.
But, if I try to import the file redisJob.py
in main.py
it gives me this error:
File ".\main.py", line 13, in <module>
from jobs.redisJob import DailyJob
File "D:\git\praw-test\jobs\redisJob.py", line 5, in <module>
import praw
File "D:\git\praw-test\env\lib\site-packages\praw\__init__.py", line 14, in <module>
from .reddit import Reddit # NOQA
File "D:\git\praw-test\env\lib\site-packages\praw\reddit.py", line 5, in <module>
from update_checker import update_check
File "D:\git\praw-test\env\lib\site-packages\update_checker.py", line 11, in <module>
import requests
File "D:\git\praw-test\env\lib\site-packages\requests\__init__.py", line 53, in <module>
major, minor, patch = urllib3_version
ValueError: not enough values to unpack (expected 3, got 1)
Just to make sure, the import command is
from jobs.redisJob import DailyJob
Did I do something wrong?
Update
I found a workaround.
I just need to import urllib3
in my main.py
then assigning the correct version.
import urllib3
urllib3.__version__ = '1.21.1'
from jobs.redisJob import DailyJob
These three lines have to be on top of my script.
It appears that you're importing under a different environment. Different launch techniques can spawn different processes and shells; this could lead to the environment variable having a value other than expected.
I don't know enough SDE details to give you a definitive solution, but I can certainly recommend a simple debugging line. Just before the problem line, insert
print urllib3_version
See what you get for the value in each launch method. I expect that there's some implementation detail, such as the values being concatenated somehow, or having some missing.
You can work around this with a check:
if len(urllib3_version) == 3:
major, minor, patch = urllib3_version
else:
# This will depend on what you see in the single value
You may need to split a string, supply defaults for missing values, or some other adaptation.