I'm trying to turn my python project into .exe
I used : pyinstaller --onefile main.py
Then I moved the main.exe into the original file to be sure it can access all the dependencies.
When I run the main.exe, I get an error, failed to execute script main.
I typed cmd in the directory of the python project, and tried python main.py
It gave me this error :
Traceback (most recent call last):
File "main.py", line 3, in <module>
from PyQt5 import QtWidgets, QtCore
ModuleNotFoundError: No module named 'PyQt5'
Even though every module are installed, why is it telling me that?
Thank you.
You haven't installed pyqt5.
Try pip install pyqt5 or pip3 install pyqt5
for linux
sudo apt install python3-pyqt5
Related
Hi I generated a pyc with python -m compileall file.py
The program works in Pycharm and pandas is installed in venv but when I launch the pyc without the venv interpretor or on another machine it says Module not Found.
Panda module is found when I install pandas outside the venv.
Do I have to do pip install all modules on every environment or is there a way for the .pyc to work without installing modules on the host ?
project
$ python PXAGIRA01.cpython-37.pyc
Traceback (most recent call last):
File "_SOURCES/PXAGIRA01.py", line 4, in
ModuleNotFoundError: No module named 'pandas'
I´ve installed and uninstalled pygame several times, I tried with pip/pip3 and still appears the following error:
Traceback (most recent call last):
File "c:\Users\josel\Desktop\Programación\Python\pygame\test\main.py", line 3, in <module>
import pygame
ModuleNotFoundError: No module named 'pygame'
I also executed "pip install pygame" in the vsc terminal and gave this message:
Requirement already satisfied: pygame in c:\users\josel\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (2.0.1)
Edit:
The output of
import sys
print(sys.path)
is:
['c:\\Users\\josel\\Desktop\\Programación\\Python\\pygame\\test', 'C:\\Users\\josel\\AppData\\Local\\Programs\\Python\\Python39\\python39.zip', 'C:\\Users\\josel\\AppData\\Local\\Programs\\Python\\Python39\\DLLs', 'C:\\Users\\josel\\AppData\\Local\\Programs\\Python\\Python39\\lib', 'C:\\Users\\josel\\AppData\\Local\\Programs\\Python\\Python39', 'C:\\Users\\josel\\AppData\\Roaming\\Python\\Python39\\site-packages', 'C:\\Users\\josel\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages', 'C:\\Users\\josel\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\win32', 'C:\\Users\\josel\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\win32\\lib', 'C:\\Users\\josel\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\Pythonwin']
A short way to fix this is using a venv
python3 -m venv venv
source ven/bin/activate
pip install pygame
keep the venv activated when you run the code
use
which python # check if VSC is using the right interpreter
I did a fresh python3 installation on OSX via homebrew:
brew install python3
Then I created a virtual environment for my project and installed scipy and scikits.samplerate:
virtualenv -p /usr/local/bin/python3 pythen_env
pip install scipy
pip install scikits.samplerate
However, when I try to import a function from scikits.samplerate, I get the following error:
>>> from scikits.samplerate import resample
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/my/project/path/pythen_env/lib/python3.6/site-packages/scikits/samplerate/__init__.py", line 4, in <module>
from info import __doc__
ModuleNotFoundError: No module named 'info'
Info happens to be the first module from the package itself that is imported in __init__.py.
Strangely, the module info.py exists in /my/project/path/pythen_env/lib/python3.6/site-packages/scikits/samplerate/:
ls /my/project/path/pythen_env/lib/python3.6/site-packages/scikits/samplerate/
__init__.py setup.py tests __pycache__
info.py setuphelp.py version.py
The error also happens when I try the same without virtualenv, as well as for other packages. How could I start to debug this issue?
The problem seems to be that the package scikits.samplerate does not support Python 3.X (see issue). However, there is a fork which supports Python 3.X. You can install it via
$ pip install git+https://github.com/gregorias/samplerate.git
As always: people can make anything they like in repositories. I did not check which changes gregorias made.
the git version does support py3
https://github.com/cournape/samplerate
(merged the PR from #gregorias)
I should find the time and procedure to update pypi too...
I am running Python3.5 on Ubuntu via SSH and I have some errors there. I don't get why. If I run the following commands I get the respective errors:
(venv) root#servername: python3 __init__.py
File "__init__.py", line 1, in <module> import flask
ImportError: No module named 'flask'
If I run it with sudo like this, I get another Error:
(venv) root#servername: sudo python3 __init__.py
File "__init__.py", line 2, in <module> from .content_management import Content
SystemError: Parent module '' not loaded, cannot perform relative import
AND if I run it with Firefox, cause its a Flask App, the website works and shows NO ERRORS! Whats going on here??? I am going crazy with this!!
Seems that you didn't install Flask module on the machine where you run your python script. That produces the ImportError you get.
Install the Flask module e.g. using pip:
$ pip install Flask
After you've done so, Python should be able to load the module.
I'm trying to install xlutils package to access xls sheets in Python but unfortunately I'm unable to install it.
Python Version=3.1.1
I downloaded the tar file from this location-http://pypi.python.org/pypi/xlutils to python31/tools/scripts directory..This is where my setup.py is located..
Then tried to unzip using 7Z file and run the setup.py install command from this directory.
and got the following..Ran the
C:\Python31\Tools\Scripts>setup.py install
running install
running build
running build_scripts
running install_scripts
running install_egg_info
Removing C:\Python31\Lib\site-packages\UNKNOWN-0.0.0-py3.1.egg-info
Writing C:\Python31\Lib\site-packages\UNKNOWN-0.0.0-py3.1.egg-info
>>> import xlutils
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
import xlutils
ImportError: No module named xlutils
Do I need to install xlrd and xlwt before installing xlutils?
Please provide your inputs
You're running setup.py from the wrong folder - you need to run it where you've unpacked the zip file.
Yes, it does need xlrd and xlwt - See here
xlrd and xlwt aren't available for Python 3 yet (I'm working on it for xlrd).
Today I have the same problem. You can try the below steps:
Install xlrd and xlwt;
Install setuptools
Install xlutils.
Good Luck.