August 22, 2013 at 5:37 am #8557
Hope i can ask some question regarding this issue, i installed python in windows & qrcode(https://pypi.python.org/pypi/qrcode). everything works fine when i test from python interpreter, but when i test using some scripts like this:
qr = qrcode.QRCode(version=1,box_size=10, border=4)
img = qr.make_image()
And running the script from cmd it show error:
Traceback (most recent call last):
File "qtest.py", line 3, in
qr = qrcode.QRCode()
AttributeError: 'module' object has no attribute 'QRCode'
I already reinstalled the qrcode(both from source/pip), python, try to repath the site-packages but it’s not work either …
Hope there’s someone can enlight me about this issue.
Thank’s a lot & sorry,
August 22, 2013 at 11:38 am #53420El33tsamuraiParticipant
What have you tried from your research already, such as things found on good? Don’t want to share something that you have tried already.
August 22, 2013 at 7:44 pm #53421
Can you provide any further information, regarding HOW you’re trying to run the code, outside of the interpreter?
I ran your script, as you’ve written it, on Python 2.7.1, with no issues, after adding the Imaging and six libraries.
August 22, 2013 at 7:52 pm #53422
Incidentally, RedHat has a bug that looked remarkably similar, as of 2 weeks ago…
Betting one of your imports is bad, somewhere.
August 23, 2013 at 1:14 am #53423
Thank’s for your reply,
– what i did is trying to repath the python path & scripts & lib in environment variable because i used this on windows
– i ran my script in command prompt using this way: python script.py, just like that, however if i trying the code in interpreter, it works fine.
I already try this in another pc (windows system too) using python 2.7.2 – it’s not work too … (not yet test in linux system).
Thank’s a lot & pardon me .
August 23, 2013 at 6:16 pm #53424
Apologies, but without seeing this one, in action, it’s pretty tough to tell you exactly what’s wrong.
I can tell you that I duplicated this, ON WINDOWS, and it works fine for me, both from within the interpreter, from “python script.py” and from running the py direct from within windows explorer.
My gut tells me something still isn’t quite right with your pathing, etc. I’d also be inclined to think one of your dependency libs that get included is bad, but that shouldn’t affect it differently when run from commandline versus interpreter.
Only other possibility I could think of would be, do you have multiple versions of python installed, such that when calling python it’s getting a different version than the interpeted version you’re running? (Doubtful, as you likely just started the interpreter via the ‘python’ command, as well, but…)
But again, it works fine for me, regardless of where and how I run it. And again, someone hit a snag in the RedHat world, with that bugzilla entry, which threw the exact same error message as yours.
What happens if you run it using pdb:
python -m pdb script.py
Then you can step through and see if a certain step does anything unexpected. Some commands in pdb (more can be found in online docs):
b: set a breakpoint
c: continue debugging until you hit a breakpoint
s: step through the code
l: list all the variables in the current scope
u: navigate up a stack frame
d: navigate down a stack frame
You can use s, for instance, to step through, and see it load all dependencies, along the way, and try to see if something is behaving differently than expected (granted, could be a long process, but might be helpful)
August 27, 2013 at 4:04 am #53425
Hi all, my apologies for my stupidity, the issue already solved, because in folder code already exist file qrcode (built in function, i try to made), whatever its hidden file, so i just move away that file.
Hayabusa, thank’s a lot for your tips, it give me an idea for every line running within code.
Thank’s a lot & once again, pardon me about this.
August 27, 2013 at 3:06 pm #53426
No worries. Glad to have given you some ideas, and glad you figured out your issue.
Good luck with your continued learning, etc!
You must be logged in to reply to this topic.