Giter Club home page Giter Club logo

Comments (19)

belono avatar belono commented on May 29, 2024 1

It seems like a python version mismatch.

Yes! When I ran it with python3.9 qrcode_linktree.py, it worked.

Each python version has its own sites-packages folder so you can't import a library that was installed with a different python version.

  • Do you have different versions of python installed on your system?

Yes, for compatibility reasons, I do. Ok, so how do I fix this long-term?

Well, virtual environments are a good solution. I use pyenv for simplicity and power. In addition to managing the virtual environment automatically by folder, it allows you to install the version of python you want on your system. Also, it integrates very well with the most popular IDEs.
There are plenty of pyenv tutorials out there that will provide you with the information you need to use it.

from python-escpos.

patkan avatar patkan commented on May 29, 2024

Hi, on which version of the library are you working? Please try adding --pre to pip, as currently the version that supports all of this is not in pypi yet. (We are in the process of finishing the release)
Otherwise, I would suspect that pip has installed version 2.2.0

from python-escpos.

matiasw avatar matiasw commented on May 29, 2024

The thing is, I used to have some ancient version of python-escpos which worked. I only tried installing again after running into these problems.
I noticed a warning from the install process that I did not catch before: WARNING: python-escpos 2.2.0 does not provide the extra 'all'. Otherwise, it seems you are correct, and the installed version is 2.2.0: Requirement already satisfied: python-escpos [...] (2.2.0)

from python-escpos.

patkan avatar patkan commented on May 29, 2024

OK, so either you try to install that old version, or you try it with --pre in order to install the most recent pre-release.

from python-escpos.

matiasw avatar matiasw commented on May 29, 2024

I should have clarified that I already did the install with pip install python-escpos --pre, but only got the Requirement already satisfied message. With pip install python-escpos[all] --pre, I get the same, but with an added WARNING: python-escpos 2.2.0 does not provide the extra 'all'. As for the old version, I wish I could go back to it, but I no longer have it installed and do not know what version it was.

from python-escpos.

belono avatar belono commented on May 29, 2024

Hi @matiasw and thanks for your interest in python-escpos.

The latest version published to pypi was v.3.0a9 on May-11, however the ability for automatically install optional dependencies (the [all] tag) is later. It was merged into master through #546 on August-16 so that feature has not been published to pypi, yet.

Your options are:

Install optional dependencies manually:
Use USB connection: pip install pyusb
Use Serial connection: pip install pyserial
Use CUPS client on non Windows: pip install pycups
Use Win32 client on Windows: pip install pywin32

And then:

  • (Recommended) Install python-escpos v.3.0.a9 through pypi:
    pip install python-escpos --pre

  • Or install the in-development version from master sources using git:
    git clone https://github.com/python-escpos/python-escpos.git
    git submodule update --init --recursive
    pip install -e \python-escpos
    Note that maybe I made some typo as it is some time since I used this installation mode.

from python-escpos.

matiasw avatar matiasw commented on May 29, 2024

Thanks for trying to help, @belono , but as I said, pip install python-escpos --pre does not install python-escpos 3.0.a9, or indeed anything later than 2.2.0.
Here is the full output:

pip install python-escpos --pre
Requirement already satisfied: python-escpos in c:\users\matia\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (2.2.0)
Requirement already satisfied: pyusb>=1.0.0 in c:\users\matia\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from python-escpos) (1.2.1)
Requirement already satisfied: Pillow>=2.0 in c:\users\matia\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from python-escpos) (9.1.0)
Requirement already satisfied: qrcode>=4.0 in c:\users\matia\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from python-escpos) (7.3.1)
Requirement already satisfied: pyserial in c:\users\matia\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from python-escpos) (3.5)
Requirement already satisfied: six in c:\users\matia\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from python-escpos) (1.16.0)
Requirement already satisfied: appdirs in c:\users\matia\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from python-escpos) (1.4.4)
Requirement already satisfied: pyyaml in c:\users\matia\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from python-escpos) (6.0)
Collecting argparse (from python-escpos)
  Using cached argparse-1.4.0-py2.py3-none-any.whl (23 kB)
Requirement already satisfied: argcomplete in c:\users\matia\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from python-escpos) (2.0.0)
Requirement already satisfied: colorama in c:\users\matia\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from qrcode>=4.0->python-escpos) (0.4.4)
Installing collected packages: argparse
Successfully installed argparse-1.4.0

from python-escpos.

matiasw avatar matiasw commented on May 29, 2024
  • Or install the in-development version from master sources using git:
    git clone https://github.com/python-escpos/python-escpos.git
    git submodule update --init --recursive
    pip install -e \python-escpos
    Note that maybe I made some typo as it is some time since I used this installation mode.

I did this, with the same result as before:

Traceback (most recent call last):
  File "C:\work\code\python-escpos2\qrcode_linktree.py", line 3, in <module>
    from escpos.printer import Usb
ImportError: No module named escpos.printer

from python-escpos.

matiasw avatar matiasw commented on May 29, 2024

I also got is not recognized as an internal or external command, operable program or batch file. for python-escpos, because it is not added to PATH by this process. Running it directly, this is the output:

C:\Users\matia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Scripts\python-escpos.exe
Traceback (most recent call last):
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\matia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Scripts\python-escpos.exe\__main__.py", line 4, in <module>
  File "C:\work\code\python-escpos2\python-escpos\src\escpos\cli.py", line 25, in <module>
    from . import config
  File "C:\work\code\python-escpos2\python-escpos\src\escpos\config.py", line 10, in <module>
    from . import exceptions, printer
  File "C:\work\code\python-escpos2\python-escpos\src\escpos\printer\__init__.py", line 4, in <module>
    from .cups import CupsPrinter
  File "C:\work\code\python-escpos2\python-escpos\src\escpos\printer\cups.py", line 16, in <module>
    from ..escpos import Escpos
  File "C:\work\code\python-escpos2\python-escpos\src\escpos\escpos.py", line 24, in <module>
    from escpos.capabilities import get_profile
  File "C:\work\code\python-escpos2\python-escpos\src\escpos\capabilities.py", line 178, in <module>
    ProfileBaseClass: Any = get_profile_class("default")
  File "C:\work\code\python-escpos2\python-escpos\src\escpos\capabilities.py", line 158, in get_profile_class
    profiles: Dict[str, Any] = CAPABILITIES["profiles"]
TypeError: string indices must be integers

from python-escpos.

matiasw avatar matiasw commented on May 29, 2024

The install-time warning is as follows:
WARNING: The script python-escpos.exe is installed in 'C:\Users\matia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Scripts' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

from python-escpos.

belono avatar belono commented on May 29, 2024

I can't reproduce your issue on a fresh python-escpos install in my Windows VM.

Let's try this:

1 - Use a global import statement:

import` escpos.printer as printer

p = printer.Usb(0x0416, 0xaabb)

2 - If the above fails:
What about uninstalling the previous installation and then re-install forcing an specific pypi version?

pip uninstall python-escpos
pip install python-escpos==3.0.a9

from python-escpos.

matiasw avatar matiasw commented on May 29, 2024

1 - Use a global import statement:

import` escpos.printer as printer

p = printer.Usb(0x0416, 0xaabb)
python3
Python 3.9.13 (tags/v3.9.13:6de2ca5, May 17 2022, 16:36:42) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import escpos.printer as printer
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\work\code\python-escpos\src\escpos\printer\__init__.py", line 4, in <module>
    from .cups import CupsPrinter
  File "C:\work\code\python-escpos\src\escpos\printer\cups.py", line 16, in <module>
    from ..escpos import Escpos
  File "C:\work\code\python-escpos\src\escpos\escpos.py", line 24, in <module>
    from escpos.capabilities import get_profile
  File "C:\work\code\python-escpos\src\escpos\capabilities.py", line 178, in <module>
    ProfileBaseClass: Any = get_profile_class("default")
  File "C:\work\code\python-escpos\src\escpos\capabilities.py", line 158, in get_profile_class
    profiles: Dict[str, Any] = CAPABILITIES["profiles"]
TypeError: string indices must be integers

2 - If the above fails: What about uninstalling the previous installation and then re-install forcing an specific pypi version?

pip uninstall python-escpos pip install python-escpos==3.0.a9

pip uninstall python-escpos
Found existing installation: python-escpos 3.0a10.dev45+g5d3d2ca
Uninstalling python-escpos-3.0a10.dev45+g5d3d2ca:
  Would remove:
    c:\users\matia\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\scripts\python-escpos.exe
    c:\users\matia\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages\__editable__.python_escpos-3.0a10.dev45+g5d3d2ca.pth
    c:\users\matia\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages\python_escpos-3.0a10.dev45+g5d3d2ca.dist-info\*
Proceed (Y/n)?
  Successfully uninstalled python-escpos-3.0a10.dev45+g5d3d2ca

C:\work\code>pip install python-escpos==3.0.a9
Collecting python-escpos==3.0.a9
  Downloading python_escpos-3.0a9-py3-none-any.whl.metadata (5.4 kB)
Requirement already satisfied: Pillow>=2.0 in c:\users\matia\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from python-escpos==3.0.a9) (9.1.0)
Requirement already satisfied: PyYAML in c:\users\matia\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from python-escpos==3.0.a9) (6.0)
Requirement already satisfied: appdirs in c:\users\matia\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5Requirement already satisfied: argcomplete in c:\users\matia\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from python-escpos==3.0.a9) (2.0.0)
Collecting argparse (from python-escpos==3.0.a9)
  Using cached argparse-1.4.0-py2.py3-none-any.whl (23 kB)
Requirement already satisfied: future in c:\users\matia\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from python-escpos==3.0.a9) (0.18.3)
Requirement already satisfied: pyserial in c:\users\matia\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from python-escpos==3.0.a9) (3.5)
Requirement already satisfied: python-barcode<1,>=0.9.1 in c:\users\matia\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from python-escpos==3.0.a9) (0.15.1)
Requirement already satisfied: pyusb>=1.0.0 in c:\users\matia\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from python-escpos==3.0.a9) (1.2.1)
Requirement already satisfied: qrcode>=4.0 in c:\users\matia\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from python-escpos==3.0.a9) (7.3.1)
Requirement already satisfied: setuptools in c:\program files\windowsapps\pythonsoftwarefoundation.python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\site-packages (from python-escpos==3.0.a9) (58.1.0)
Requirement already satisfied: six in c:\users\matia\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from python-escpos==3.0.a9) (1.16.0)
Requirement already satisfied: colorama in c:\users\matia\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from qrcode>=4.0->python-escpos==3.0.a9) (0.4.4)
Downloading python_escpos-3.0a9-py3-none-any.whl (48 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 48.7/48.7 kB 1.2 MB/s eta 0:00:00
Installing collected packages: argparse, python-escpos
  WARNING: The script python-escpos.exe is installed in 'C:\Users\matia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed argparse-1.4.0 python-escpos-3.0a9

C:\work\code>python-escpos
'python-escpos' is not recognized as an internal or external command,
operable program or batch file.

And if I run it directly:

C:\Users\matia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Scripts\python-escpos.exe
Traceback (most recent call last):
  File "C:\Users\matia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\escpos\config.py", line 74, in load
    with open(config_path, "rb") as config_file:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\matia\\AppData\\Local\\python-escpos\\python-escpos\\config.yaml'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\matia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Scripts\python-escpos.exe\__main__.py", line 7, in <module>
  File "C:\Users\matia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\escpos\cli.py", line 545, in main
    saved_config.load(config_path)
  File "C:\Users\matia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\escpos\config.py", line 77, in load
    raise exceptions.ConfigNotFoundError(
escpos.exceptions.ConfigNotFoundError: Configuration not found (Couldn't read config at C:\Users\matia\AppData\Local\python-escpos\python-escpos\config.yaml)

from python-escpos.

belono avatar belono commented on May 29, 2024

Please try setting this environment variable at your prompt:

set ESCPOS_CAPABILITIES_FILE=C:\work\code\python-escpos\capabilities-data\capabilities.json

or wherever the capabilities.json file is located in your python-escpos installation.

from python-escpos.

patkan avatar patkan commented on May 29, 2024

Thanks for trying to help, @belono , but as I said, pip install python-escpos --pre does not install python-escpos 3.0.a9, or indeed anything later than 2.2.0. Here is the full output:

pip install python-escpos --pre
Requirement already satisfied: python-escpos in c:\users\matia\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (2.2.0)
Requirement already satisfied: pyusb>=1.0.0 in c:\users\matia\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from python-escpos) (1.2.1)
Requirement already satisfied: Pillow>=2.0 in c:\users\matia\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from python-escpos) (9.1.0)
Requirement already satisfied: qrcode>=4.0 in c:\users\matia\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from python-escpos) (7.3.1)
Requirement already satisfied: pyserial in c:\users\matia\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from python-escpos) (3.5)
Requirement already satisfied: six in c:\users\matia\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from python-escpos) (1.16.0)
Requirement already satisfied: appdirs in c:\users\matia\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from python-escpos) (1.4.4)
Requirement already satisfied: pyyaml in c:\users\matia\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from python-escpos) (6.0)
Collecting argparse (from python-escpos)
  Using cached argparse-1.4.0-py2.py3-none-any.whl (23 kB)
Requirement already satisfied: argcomplete in c:\users\matia\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from python-escpos) (2.0.0)
Requirement already satisfied: colorama in c:\users\matia\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from qrcode>=4.0->python-escpos) (0.4.4)
Installing collected packages: argparse
Successfully installed argparse-1.4.0

If a pip requirement is already satisfied (installed), you need to tell pip that it should upgrade to the newest version by also adding --upgrade.

from python-escpos.

matiasw avatar matiasw commented on May 29, 2024

Please try setting this environment variable at your prompt:

set ESCPOS_CAPABILITIES_FILE=C:\work\code\python-escpos\capabilities-data\capabilities.json

or wherever the capabilities.json file is located in your python-escpos installation.

It was actually under dist in that directory. After setting it, I get

set ESCPOS_CAPABILITIES_FILE=C:\work\code\python-escpos\capabilities-data\dist\capabilities.json

C:\work\code>C:\Users\matia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Scripts\python-escpos.exe
Traceback (most recent call last):
  File "C:\Users\matia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\escpos\config.py", line 74, in load
    with open(config_path, "rb") as config_file:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\matia\\AppData\\Local\\python-escpos\\python-escpos\\config.yaml'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\matia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Scripts\python-escpos.exe\__main__.py", line 7, in <module>
  File "C:\Users\matia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\escpos\cli.py", line 545, in main
    saved_config.load(config_path)
  File "C:\Users\matia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\escpos\config.py", line 77, in load
    raise exceptions.ConfigNotFoundError(
escpos.exceptions.ConfigNotFoundError: Configuration not found (Couldn't read config at C:\Users\matia\AppData\Local\python-escpos\python-escpos\config.yaml)

If a pip requirement is already satisfied (installed), you need to tell pip that it should upgrade to the newest version by also adding --upgrade.

I already have used that switch, as in pip install python-escpos --pre --upgrade. 3.0.9a is now seemingly installed (the version number has changed to 3.0.9a in the already satisfied message), but the installation is somehow totally borked and can't find anything.

from python-escpos.

belono avatar belono commented on May 29, 2024

It was actually under dist in that directory. After setting it, I get

set ESCPOS_CAPABILITIES_FILE=C:\work\code\python-escpos\capabilities-data\dist\capabilities.json

C:\work\code>C:\Users\matia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Scripts\python-escpos.exe
Traceback (most recent call last):
  File "C:\Users\matia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\escpos\config.py", line 74, in load
    with open(config_path, "rb") as config_file:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\matia\\AppData\\Local\\python-escpos\\python-escpos\\config.yaml'

Ok. If I'm not mistaken:

  1. You have a problem with your path not finding the python-escpos command. You must add C:\Users\matia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Scripts\ to your PATH in order to call python-escpos.exe from everywhere. Otherwise, as you already checked, you have to cd to that folder if you want to run the file.
  2. You are using the python-escpos CLI but you don't have a config file.
    In order to use the python-escpos CLI you need to provide a config.yaml file with the configuration of the connection to the printer as is documented at the python-escpos docs
    The first FileNotFoundError is telling you that.
    So create a new file named config.yaml and add the following content, save and close:
printer:
        type: Usb
        idVendor: 0x0416
        idProduct: 0xaabb

Then call the python-escpos CLI adding the -c option pointing to your newly created config.yaml
python-escpos -c <path-to-config.yaml> <print-commands>

Note that you still need the ESCPOS_CAPABILITIES_FILE environment variable to be set before running python-escpos.exe.

from python-escpos.

matiasw avatar matiasw commented on May 29, 2024

Ok, I finally got it working with the CLI tool, but my code will still not work, even after setting PATH:

Traceback (most recent call last):
  File "C:\work\code\python-escpos\qrcode_linktree.py", line 3, in <module>
    from escpos.printer import Usb
ImportError: No module named escpos.printer

Edit: to clarify about the PATH: pip show python-escpos gives:

Name: python-escpos
Version: 3.0a9
Summary: Python library to manipulate ESC/POS Printers
Author: Manuel F Martinez and others
Author-email: [email protected]
License: MIT
Location: c:\users\matia\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages
Requires: appdirs, argcomplete, argparse, future, Pillow, pyserial, python-barcode, pyusb, PyYAML, qrcode, setuptools, six
Required-by:

and c:\users\matia\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages is in PATH. Shouldn't this be enough?

from python-escpos.

belono avatar belono commented on May 29, 2024

It seems like a python version mismatch.

  • Do you have different versions of python installed on your system?
  • Are you using some kind of 'virtual env', venv, pyenv, pipenv, that you forgot to activate?
  • What if you specify the python version when installing via pip?
    python3.9 -m pip install python-escpos==3.0a9

from python-escpos.

matiasw avatar matiasw commented on May 29, 2024

It seems like a python version mismatch.

Yes! When I ran it with python3.9 qrcode_linktree.py, it worked.

  • Do you have different versions of python installed on your system?

Yes, for compatibility reasons, I do.
Ok, so how do I fix this long-term?

from python-escpos.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.