I've been having a lot of trouble converting one of my python projects into an executable with the use of pyinstaller. Upon launching the .exe, it gives this rather simple error that I just can't get my head around. The script works as intended in the editor (pycharm in this case).
In pyinstaller there is a single warning message displayed, "Hidden import "pygame._view" not found!"
I've tried using 32 and 64 bit versions of pygame, reinstalled several times and purged pip cache history.
I'm aware images aren't liked around here, but the .exe only remains open for one frame, I simply don't have enough time to copy the actual text.
Full error message
If the code works fine in pycharm, then it might just be an issue with importing the module in the script. At least that's what the error emssage seems to be saying. Do you specifically import pygame.base or the like in the __init__.py script?
Related
I'm fairly new to IDE's and I'm trying to take courses in Python. No matter what I try, I cannot successfully run a python script that has import pandas and import numpy in it in either Visual Studio Code or Eclipse (running on Windows 10). I have Python 3.8 installed, and when I try running those commands in the shell it works fine. I suspect when I try executing an actual Python script instead of using the console, it might be using a different interpreter, and I only get errors when I try doing this, saying numpy is not defined. I also get the error "cannot import name 'numpy' from partially initialized module 'pandas' (most likely due to a circular import)" when I specify "from pandas import numpy" rather than "from pandas import *".
I am very frustrated and don't know how to fix this problem. I've tried searching for help but not having a programming background, I don't know where to go to resolve this or how.
I also cannot get pip or pip3 to work at all to install packages. Those commands don't get recognized.
Please help!
I recommend using Jupyter Notebooks/pycharm(IDE). Both are very useful for learning python and working with data, data manipulation, and data visualizations.
PyCharm knows everything about your code. Rely on it for intelligent code completion, on-the-fly error checking and quick-fixes & easy project navigation.
While
Jupyter Notebooks can run line by line, rerun specific lines after making changes, and it's inline output is very useful for debugging and visualizations. You can get it from https://jupyter.org.
Zepellin Notebooks can also serve as alternatives.
I have written a python script that uses cvlib library, when i run the code as a python scrept it works fine, however; when i converted the code into an exe file, everything seems to work fine, apart from importing cvlib library.
The error shows up like the follwoing:
pkg_resources.DistributionNotFound: The 'cvlib' distribution was not found and is required by the application
The detailed Error
Has anyone face this problem before ? if so, could you please provide me the proper way of fixing it as i think there are some dependencies issue.
I figured out finally what the problem was, Pyinstaller sometimes is not able to include some libraries that we import in our (.py) file. So, When Pyinstaller creates the (.exe) file, it agnores some imports, so the solution is to copy the folder of these imports, For example, cvlib forlder and paste it as it is in the same location as your (.exe) file.
I am trying to convert my .py file to an exe file. I've done it in the past but for some reason it isn't working anymore. I am using Python 2.7 and have other versions installed as well but my application won't work without 2.7. If I do python activityKivy.py it runs perfectly. I also tried with py2exe but was unsuccessful, it gave me too many dll warnings and would crash each time I open it. I prefer to stick with pyinstaller because thats what always worked for me. Some help would greatly be appreciates!
error screenshot
**Update: I wasn't able to figure out exactly what the problem was but I was playing around with my environment variables and changing my pip names to pip2 pip3 and thats when this problem started happening and even when I reverted all my changes it still showed me this.I was able to fix it by simply uninstalling pyinstaller and redownloading it.
This is the first time I have attempted to use anything other than what's provided by python.
I have recently gotten into pythons provided Tkinter, though due to some issues I decided to use another GUI, and heard that PyQt was highly recommended, so I downloaded that and looked into various tutorials. In these tutorials, I cannot seem to execute any of the import statements in said tutorials that relate to PyQt, primarily PyQt5 (I have checked I have the correct version number by the way).
So for instance:
import PyQt5
raises the error:
Traceback (most recent call last):
File "/Users/MEBO/PycharmProjects/Music/testing.py", line 1, in <module>
import Qt
ImportError: No module named 'Qt'
[Finished in 0.1s with exit code 1]
I have a lot of research into this. I've heard people talk of using pip to install modules, and I have done this be safe (as well as downloading it from the internet), I've tried changing the project interpreter to versions Python3/ 2.7/ 2.6, appending the path name to the sys.path directory, (which I really know nothing about to be honest, I was hoping I'd get lucky), though nothing seems to work.
Are you supposed to be able to just import a module off the bat, or do you have to set some things up first?
For windows download the package and extract it to (path where python installed)\Python27\Lib and then try to import.
Specific to PyQt
This package cannot just be downloaded and imported, it must be built because it is not pure python, it uses Qt (C++) and requires dependancies. Read this tutorial on installation.
There is also a very complete python package distribution, Anaconda, that includes pyqt and much more. Almost all the packages I ever looked at are in there.
In general to pure python code
In other cases, if you place modules/code that has been download into the directory that your python script is run from, you can import off the bat, or you can append/insert any folder to the sys.path.
# importer will search here last
sys.path.append('/path/to/code/')
# importer will search here second, right after script's directory
# this can be useful to override a module temporarily...
sys.path.insert(1,'/path/to/code/')
Hey i want to export my Python Selenium Projekt with Pyinstaller but every time when im trying to do this it wotrks but when i start the exe file i became this error:
ModuleNotFoundError: no module named 'pyfiglet.fonts'
to start pyinstaller i used this command:
pyinstaller --onefile SickoAIO.py
Without a little more information, it's hard to tell what's wrong. However, I'm going to assume some things you haven't stated and provide some ideas:
Assuming SickoAIO.py works fine before you try to use pyinstaller, sometimes if in your Python code you only imported the more general module:
import pyfiglet
but need to use pyfiglet.fonts, a "hack" for it to work in pyinstaller could be to make the import more specific:
import pyfiglet.fonts
I've not used pyfiglet, but this hack worked for me with the numpy module, for example.
Another thing that has helped me troubleshoot a similar issue with numpy, scipy, etc. is updating the versions of the module and/or pyinstaller
It's possible you may need to use hooks, especially since it seems like pyfiglet may not play well with pyinstaller. This is explained specifically for pyfiglet here:
https://hugomartins.io/essays/2019/06/pyinstaller-pyfiglet-trouble/
I didn't try it, and it looks like you may need to click on more links in that webpage as well as learn more about how hooks work in pyinstaller (https://pyinstaller.readthedocs.io/en/stable/hooks.html?highlight=hook) to understand the full issue.