ZXing in python FileNotFoundError Problem
up vote
0
down vote
favorite
I have written a simple python code to detect qrCode. Code:
import zxing
reader = zxing.BarCodeReader()
barcode = reader.decode('../images/QR_CODE-easy.png')
print(barcode)
Now, when I run it, I get following error:
FileNotFoundError: [WinError 2] The system cannot find the file specified
I have check this file location is valid by using cv.imread command. Please let me know if someone have sollution of this problem
python zxing
add a comment |
up vote
0
down vote
favorite
I have written a simple python code to detect qrCode. Code:
import zxing
reader = zxing.BarCodeReader()
barcode = reader.decode('../images/QR_CODE-easy.png')
print(barcode)
Now, when I run it, I get following error:
FileNotFoundError: [WinError 2] The system cannot find the file specified
I have check this file location is valid by using cv.imread command. Please let me know if someone have sollution of this problem
python zxing
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have written a simple python code to detect qrCode. Code:
import zxing
reader = zxing.BarCodeReader()
barcode = reader.decode('../images/QR_CODE-easy.png')
print(barcode)
Now, when I run it, I get following error:
FileNotFoundError: [WinError 2] The system cannot find the file specified
I have check this file location is valid by using cv.imread command. Please let me know if someone have sollution of this problem
python zxing
I have written a simple python code to detect qrCode. Code:
import zxing
reader = zxing.BarCodeReader()
barcode = reader.decode('../images/QR_CODE-easy.png')
print(barcode)
Now, when I run it, I get following error:
FileNotFoundError: [WinError 2] The system cannot find the file specified
I have check this file location is valid by using cv.imread command. Please let me know if someone have sollution of this problem
python zxing
python zxing
edited Nov 18 at 6:03
asked Nov 11 at 11:31
Hasan Iqbal
189
189
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
You appear to be on Windows (as the error code suggests), which uses the backslash for file paths.
It's not good practice as it won't be widely compatible, but if you're in a hurry and know you won't want to use the code on Mac or Linux, you can use double backslashes:
reader.decode('..\images\QR_CODE-easy.png')
Otherwise you should use os.path.join or pathlib (assuming your using Python 3)
import os.path
qr_file = os.path.join("..", "images", "QR_CODE-easy.png")
Or
from pathlib import Path
qr_file = Path("../images/QR_CODE-easy.png")
There are further details of a few options here:
https://medium.com/@ageitgey/python-3-quick-tip-the-easy-way-to-deal-with-file-paths-on-windows-mac-and-linux-11a072b58d5f
Edit: it is also worth confirming that your relative path is indeed correct when starting in your current working directory. You can check the current working directory with: cwd = os.getcwd() . You may want to try an absolute path to your file too, just to confirm whether it works with that first.
More details on cwd here: https://stackoverflow.com/a/5137509/142780
I did all the remedies you mentioned, but the same problem persists. Its really frustrating. I think zxing don't work on python3
– Hasan Iqbal
Nov 16 at 8:31
Sorry to hear that. According to the README in the repo, it is compatible with Python 3: github.com/dlenski/python-zxing/blob/master/README.md
– Neil
Nov 17 at 10:43
I've added a point about confirming your current working directory and suggest trying an absolute path just to be 100% sure it's not a mix up with the relative path
– Neil
Nov 17 at 10:44
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
You appear to be on Windows (as the error code suggests), which uses the backslash for file paths.
It's not good practice as it won't be widely compatible, but if you're in a hurry and know you won't want to use the code on Mac or Linux, you can use double backslashes:
reader.decode('..\images\QR_CODE-easy.png')
Otherwise you should use os.path.join or pathlib (assuming your using Python 3)
import os.path
qr_file = os.path.join("..", "images", "QR_CODE-easy.png")
Or
from pathlib import Path
qr_file = Path("../images/QR_CODE-easy.png")
There are further details of a few options here:
https://medium.com/@ageitgey/python-3-quick-tip-the-easy-way-to-deal-with-file-paths-on-windows-mac-and-linux-11a072b58d5f
Edit: it is also worth confirming that your relative path is indeed correct when starting in your current working directory. You can check the current working directory with: cwd = os.getcwd() . You may want to try an absolute path to your file too, just to confirm whether it works with that first.
More details on cwd here: https://stackoverflow.com/a/5137509/142780
I did all the remedies you mentioned, but the same problem persists. Its really frustrating. I think zxing don't work on python3
– Hasan Iqbal
Nov 16 at 8:31
Sorry to hear that. According to the README in the repo, it is compatible with Python 3: github.com/dlenski/python-zxing/blob/master/README.md
– Neil
Nov 17 at 10:43
I've added a point about confirming your current working directory and suggest trying an absolute path just to be 100% sure it's not a mix up with the relative path
– Neil
Nov 17 at 10:44
add a comment |
up vote
0
down vote
You appear to be on Windows (as the error code suggests), which uses the backslash for file paths.
It's not good practice as it won't be widely compatible, but if you're in a hurry and know you won't want to use the code on Mac or Linux, you can use double backslashes:
reader.decode('..\images\QR_CODE-easy.png')
Otherwise you should use os.path.join or pathlib (assuming your using Python 3)
import os.path
qr_file = os.path.join("..", "images", "QR_CODE-easy.png")
Or
from pathlib import Path
qr_file = Path("../images/QR_CODE-easy.png")
There are further details of a few options here:
https://medium.com/@ageitgey/python-3-quick-tip-the-easy-way-to-deal-with-file-paths-on-windows-mac-and-linux-11a072b58d5f
Edit: it is also worth confirming that your relative path is indeed correct when starting in your current working directory. You can check the current working directory with: cwd = os.getcwd() . You may want to try an absolute path to your file too, just to confirm whether it works with that first.
More details on cwd here: https://stackoverflow.com/a/5137509/142780
I did all the remedies you mentioned, but the same problem persists. Its really frustrating. I think zxing don't work on python3
– Hasan Iqbal
Nov 16 at 8:31
Sorry to hear that. According to the README in the repo, it is compatible with Python 3: github.com/dlenski/python-zxing/blob/master/README.md
– Neil
Nov 17 at 10:43
I've added a point about confirming your current working directory and suggest trying an absolute path just to be 100% sure it's not a mix up with the relative path
– Neil
Nov 17 at 10:44
add a comment |
up vote
0
down vote
up vote
0
down vote
You appear to be on Windows (as the error code suggests), which uses the backslash for file paths.
It's not good practice as it won't be widely compatible, but if you're in a hurry and know you won't want to use the code on Mac or Linux, you can use double backslashes:
reader.decode('..\images\QR_CODE-easy.png')
Otherwise you should use os.path.join or pathlib (assuming your using Python 3)
import os.path
qr_file = os.path.join("..", "images", "QR_CODE-easy.png")
Or
from pathlib import Path
qr_file = Path("../images/QR_CODE-easy.png")
There are further details of a few options here:
https://medium.com/@ageitgey/python-3-quick-tip-the-easy-way-to-deal-with-file-paths-on-windows-mac-and-linux-11a072b58d5f
Edit: it is also worth confirming that your relative path is indeed correct when starting in your current working directory. You can check the current working directory with: cwd = os.getcwd() . You may want to try an absolute path to your file too, just to confirm whether it works with that first.
More details on cwd here: https://stackoverflow.com/a/5137509/142780
You appear to be on Windows (as the error code suggests), which uses the backslash for file paths.
It's not good practice as it won't be widely compatible, but if you're in a hurry and know you won't want to use the code on Mac or Linux, you can use double backslashes:
reader.decode('..\images\QR_CODE-easy.png')
Otherwise you should use os.path.join or pathlib (assuming your using Python 3)
import os.path
qr_file = os.path.join("..", "images", "QR_CODE-easy.png")
Or
from pathlib import Path
qr_file = Path("../images/QR_CODE-easy.png")
There are further details of a few options here:
https://medium.com/@ageitgey/python-3-quick-tip-the-easy-way-to-deal-with-file-paths-on-windows-mac-and-linux-11a072b58d5f
Edit: it is also worth confirming that your relative path is indeed correct when starting in your current working directory. You can check the current working directory with: cwd = os.getcwd() . You may want to try an absolute path to your file too, just to confirm whether it works with that first.
More details on cwd here: https://stackoverflow.com/a/5137509/142780
edited Nov 17 at 10:41
answered Nov 11 at 12:26
Neil
3971320
3971320
I did all the remedies you mentioned, but the same problem persists. Its really frustrating. I think zxing don't work on python3
– Hasan Iqbal
Nov 16 at 8:31
Sorry to hear that. According to the README in the repo, it is compatible with Python 3: github.com/dlenski/python-zxing/blob/master/README.md
– Neil
Nov 17 at 10:43
I've added a point about confirming your current working directory and suggest trying an absolute path just to be 100% sure it's not a mix up with the relative path
– Neil
Nov 17 at 10:44
add a comment |
I did all the remedies you mentioned, but the same problem persists. Its really frustrating. I think zxing don't work on python3
– Hasan Iqbal
Nov 16 at 8:31
Sorry to hear that. According to the README in the repo, it is compatible with Python 3: github.com/dlenski/python-zxing/blob/master/README.md
– Neil
Nov 17 at 10:43
I've added a point about confirming your current working directory and suggest trying an absolute path just to be 100% sure it's not a mix up with the relative path
– Neil
Nov 17 at 10:44
I did all the remedies you mentioned, but the same problem persists. Its really frustrating. I think zxing don't work on python3
– Hasan Iqbal
Nov 16 at 8:31
I did all the remedies you mentioned, but the same problem persists. Its really frustrating. I think zxing don't work on python3
– Hasan Iqbal
Nov 16 at 8:31
Sorry to hear that. According to the README in the repo, it is compatible with Python 3: github.com/dlenski/python-zxing/blob/master/README.md
– Neil
Nov 17 at 10:43
Sorry to hear that. According to the README in the repo, it is compatible with Python 3: github.com/dlenski/python-zxing/blob/master/README.md
– Neil
Nov 17 at 10:43
I've added a point about confirming your current working directory and suggest trying an absolute path just to be 100% sure it's not a mix up with the relative path
– Neil
Nov 17 at 10:44
I've added a point about confirming your current working directory and suggest trying an absolute path just to be 100% sure it's not a mix up with the relative path
– Neil
Nov 17 at 10:44
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53248286%2fzxing-in-python-filenotfounderror-problem%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown