0

This question is not a duplicate of this question, because I am trying to create an app.

I am currently following this tutorial, but when I try to run my app,

my command prompt prints out this error:

enter image description here

Why does this error happen and how can I solve it? I read through all the answers to the linked question, but none of them are pertinent to my problem.

Please anyone help me, I still haven't found a working solution; I am getting desperate!!!

Edit: I can't just install and uninstall pynput? Idk why it doesn't work because shouldn't pynput come with idle?

Version: 3.74 python idle, most updated version of pyinstaller

Rebecca Bibye
  • 190
  • 2
  • 18
  • Please edit your question to include the full error traceback – JeffUK Dec 17 '20 at 16:46
  • @JeffUK I just did:) Do you have any advice for me? – Rebecca Bibye Dec 17 '20 at 16:59
  • 1
    @Rebecca Bibye, When you run python myprogram.py and get an error, it means that your app is not able to run on your system. Before packaging it into an app, you need to fix it. From a traceback, it looks like there is a problem loading numpy library. Try reinstalling it. Let me know if you need help with that. – George Dec 20 '20 at 18:15
  • @George I reinstalled it, but it still doesn't work. Do you think it's because printing out a numpy table isn't compatible as an app and I'd have to format it first? – Rebecca Bibye Dec 20 '20 at 19:20
  • 1
    Could you please try importing it in python shell, specifically 32bit ? 'import numpy' and see if it works. Chance is that numpy has libraries for 64 bit system, which won't work on 32bit – George Dec 20 '20 at 19:28
  • It worked! I don't know why, but it seriously worked. Could it maybe be that my app can't find a way to print out a numpy table so it prints out an error message instead? – Rebecca Bibye Dec 20 '20 at 19:33
  • Could you please elaborate on what exactly worked? I still think the problem was incompatible numpy libraries. – George Dec 20 '20 at 21:03
  • When I entered: 'import numpy' into the shell, it really imported it (no error message at all). Should that have happened? – Rebecca Bibye Dec 20 '20 at 21:27
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/226215/discussion-between-george-and-rebecca-bibye). – George Dec 20 '20 at 22:31
  • @RebeccaBibye what's your python and pyinstall version – Chandan Dec 23 '20 at 08:37
  • I think [this answer](https://stackoverflow.com/questions/63681770/getting-error-when-using-pynput-with-pyinstaller) might help you out. – Ananth Dec 26 '20 at 17:20
  • I think [this answer](https://stackoverflow.com/questions/63681770/getting-error-when-using-pynput-with-pyinstaller) will solve your problem! – Ananth Dec 26 '20 at 17:21

3 Answers3

1

The following might help you if you haven't tried them already:

  1. Update pip from the command line
  2. Unistall pyinstaller
  3. Re-install pyinstaller and try it again

If the above does not work, try running the following command in the command line. Make sure there are some print statements in your code to see if it works.

python monitoring_culmination_product.py

If you got a message saying "python is not recognised as an internal or external command" then python might have not been added as an environment path.Try this to fix the issue. You could always re-install python if things get difficult.(make sure you install the appropriate version 32-64bit)

If the command though executed without a problem. Try to use pyinstaller on another file to see if the problem has to make sure the problem has to do with pyinstaller. From a personal experience, pyinstaller can be unreliable at times so I put the following line in my projects just to make sure. It might help you too.

import pkg_resources.py2_warn

Disclaimer: Although it is not specified I assume that you are using Windows

Rebecca Bibye
  • 190
  • 2
  • 18
RafD
  • 65
  • 1
  • 8
  • I did what you said and it didn't work! here are some problems: when I ran "python myprogram.py" it got the same original error that I had above; it recognized python but it produced another error. When I tried to import pkg_resources.py2_warn, it said: ERROR: Could not find a version that satisfies the requirement pkg_resources. What should I do now? – Rebecca Bibye Dec 17 '20 at 22:17
  • 1
    @RebeccaBibye try this command `pyinstaller --hidden-import 'packaging.version' --hidden-import 'packaging.specifiers' --hidden-import 'packaging.requirements' --hidden-import 'pkg_resources.markers' myprogram.py` – Chandan Dec 20 '20 at 01:34
  • I got the exact same error as my original command; OSError: [WinError 193] %1 is not a valid Win32 application Do you think it might be my program that is the problem or one of the packages inside the program rather than pyinstaller? – Rebecca Bibye Dec 20 '20 at 15:37
0

You could try to use conda create to get an environment containing all the need dependencies (numpy, etc) and then use pyinstaller as explained in this discussion.

mando
  • 135
  • 1
  • 8
  • I really don't want to install more stuff on my computer (like anaconda). Is there any other way? – Rebecca Bibye Dec 21 '20 at 15:39
  • You could probably use a venv, [as explained here](https://stackoverflow.com/questions/48757977/how-to-include-dependencies-from-venv-directory-when-running-pyinstaller-for-pro). – mando Dec 21 '20 at 16:46
  • I actually don't think I have pycharm either; I use idle version 3.74 – Rebecca Bibye Dec 22 '20 at 17:03
0

Please fall back to 1.6.8 version of pynput. pip install pynput==1.6.8

Ref : https://stackoverflow.com/a/63721929/14759065

Ananth
  • 815
  • 1
  • 4
  • 11