Problem statement:
I can't seem to run
'PyInstaller --onefile myfile.py'
on a file containing
import wmi
It cannot find win32api. I get a popup warning saying python has stopped etc. My console says "ImportError: No module named 'win32api'". I can run 'import win32api', 'import win32com', and 'import WMI' in python directly in the same environment without issue. I fundamentally don't understand what is wrong here.
Error message:
3469 INFO: Loading module hook "hook-pywintypes.py"...
Fatal Python error: Py_Initialize: can't initialize sys standard streams
ImportError: No module named 'win32api'
I have tried:
PyInstaller - ImportError: No module named win32api - 'import os' works fine for PyInstaller and runs fine in python.
No module named 'win32api' - Not very helpful
How to install pywin32 module in windows 7 - This is where I got the SF link (python3.5 amd64 pywin32 version)
ImportError: no module named win32api -
I thought it might be a path thing, but my installation appears to be in the correct place: "C:\Users\myuser\AppData\Local\Continuum\Anaconda3\pkgs\pywin32-220-py35_2\Lib\site-packages\win32"
I can run 'PyInstaller --onefile myscript.py' on other files, and have without issue as long as they don't use the wmi module.
I looked at the win32com _init__.py line 5 where it's messing up and it's just an import statement for win32api.
System:
Windows 7 x64, Python 3.5.3 64bit, Anaconda 4.3.14 64bit, using pyinstaller 3.2.3 (recommended by this thread), with pywin32 220 (with sourceforge download [I know, I tried pip, conda, and easy_install]) and I'm running it in cmder as an admin.
In my case, I couldn't use the module in the python shell, even if original one could. When I execute python shell as an administrator option, it was solved. Try it with administrator execution. I used python version 3.5.2 with windows x64bits.
I face this problem but I install ---> pip install pypiwin32 to solve my problems
Related
I have the following problem with fbs and Python: I tried to compile Python code and wanted to create an executable .exe file in windows. The command fbs run works fine, but fbs freeze fails.
Package versions:
Python 3.6.4
PyInstaller: 3.4
PyQt5: 5.9.2
Packages that I import:
import re
from itertools import chain
import os
import pandas
from PyQt5.QtWidgets import *
from fbs_runtime.application_context.PyQt5 import ApplicationContext
The output of fbs freeze --debug you see in the attached image:
I used the pyinstaller command to create the exe. This was possible without fbs. Just pyinstaller with the standard comments pyinstaller "...." --onefile --noconsole.
It worked with Python 3.6.4 and pyinstaller 3.4. Perhaps 3.5 would also work. But I know at least that Python 3.8.0 with the newest pyinstaller (even development version from git) doesn't work. I used PyQt5, but some older version 5.12....
It's a bit intransparent...
Best regards,
Markus
fbs runs perfectly fine with python 3.6.x (I am using 3.6.8, PyQt 5.9.2, PyInstaller 3.4).
The python compiler can sometimes get confused if another error happens earlier in the stack. Generally if fbs freeze errors when fbs run works, that points to a library-include error.
See my answer here to include necessary python library resources in your ./src/freeze/windows/ directory and try freezing again: The 'google-api-python-client' distribution was not found and is required by the application with pyinstaller
I am trying to get jupyterlab working using an environment handled by miniconda. However, starting from a fresh environment using python 3.8.0 and simply doing
conda install -c conda-forge jupyterlab
First lead me to an asyncio related error. I was able to solve it using this answer.
Now I am facing a DLL import error :
File "C:\Users\XXXX\AppData\Local\Continuum\miniconda3\lib\site-packages\zmq\backend\cython\__init__.py", line 6, in <module>
from . import (constants, error, message, context,
ImportError: DLL load failed: The specified module could not be found.
And I can't solve this. I tried using python 3.6.0 instead of 3.8.0. This did not work.
Any idea ? I am using Windows 10 build 1809 64 bits system.
I am using Ubuntu 18.10(dual Boot win10), I have installed anaconda (conda version- 4.6.7) on ubuntu. After this Installation I installed Pycharm via snap on Command Prompt. Since Pycharm(version - 2018.3.5) didnt Detect my python Location automatically I set the python Interpreter via
Adding Location ->System Interpreter (As I didn't want any Venv) -> Path
But when I try to import opencv in Pycharm it says
ModuleNotFoundError: No module named 'cv2'
Python3.6 in Anaconda Bin is shown to which I have linked in Pycharm (I have also tried other Python files there as well but no luck)
When I run in Terminal: python3 -c 'import sys; print(sys.path)'
It shows:
['', '/usr/lib/python36.zip', '/usr/lib/python3.6', '/usr/lib/python3.6
/lib-dynload', '/usr/local/lib/python3.6/dist-packages', '/usr/local
/lib/python3.6/dist-packages/setuptools-39.1.0-py3.6.egg', '/usr/lib`/python3
/dist-packages']
So could anyone help me out in this?? Thank You in Advance!!
Edit 1:
I am also unable to access any of the libraries from terminal Itself. So Could anyone help me with that as well. Should I export path of this Python in Anaconda bin folder to bashrc file in Ubuntu?
Edit 2:
The libraries affected is not just opencv. There are few other Libraries like Portaudio which are affected as well along with Opencv
I am running Python 3.5.1 and PyInstaller 3.2 on Windows.
I need to compile my script into an exe. I have done this with pyintaller before with different scripts and have had no issues. Pyinstaller is having trouble importing xlrd. I have tried:
--hidden-import=xlrd
and also
--hidden-import xlrd and neither has worked.
I have heard about hooks but I cannot find any documentation on how to set up the hook-xlrd.py file.
I have been getting the error:
ImportError: No Module called xlwt
The script runs perfectly from the Command Prompt.
Somehow, your application requires xlwt. So do a pip install xlwt and then add --hidden-import=xlwt to your arguments. For a more comprehensive guide, see here.
So I had been working with virtualenvs a couple months ago but had to stop for a while and now I don't seem to be able to get it working again.
Here is what I did
D:\CS\Python_Projects\HomeCenter>venv\Scripts\activate
(venv) D:\CS\Python_Projects\HomeCenter>pip freeze
You are using pip version 6.0.8, however version 7.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Flask==0.10.1
Flask-SQLAlchemy==2.0
itsdangerous==0.24
Jinja2==2.8
MarkupSafe==0.23
SQLAlchemy==1.0.8
waitress==0.8.9
Werkzeug==0.10.4
(venv) D:\CS\Python_Projects\HomeCenter>server.py
Traceback (most recent call last):
File "D:\CS\Python_Projects\HomeCenter\server.py", line 3, in <module>
from waitress import serve
ImportError: No module named 'waitress'
(venv) D:\CS\Python_Projects\HomeCenter>
Same happens if I were to run app.py, it won't find flask. I have been using PyCharm and when I check there it tells me the interpreter is pointing towards 3.4.2 virtualenv at D:\CS\Python_Projects\HomeCenter\venv
So why can't it find the modules?
Oh contents of server.py in case it's relevant
from waitress import serve
import os
from app import app
port = int(os.environ.get('PORT', 9999))
serve(app, host='0.0.0.0', port=port)
Hello I am korean student so I can't English not well. Please understand.
In my case, I have a well operated program but suddenly occured "not found" error like you after update mac os to BigSur.
but I finally found solution.
when before update I compiled by "source venv/fileName.py" but after update I compile by "python3 venv/fileName.py" then well operate
You try it too.
A couple of things could have happened here:
Use which python and which pip to check if both are from the virtual env itself.
As dirn suggested in the comments, it might be a PATH mixup. The packages were installed in the virtual environment but the script was executed from outside the environment interpreter. (Use venv\Scripts\python.exe <filename.py> instead of just filename to execute).