I found several topics relating to this issue (when I try to run python.exe in command line, I get the subject error message), but none of the suggestions worked for me. I have installed and uninstalled around 5 times now. I wasn't getting this error earlier tonight after first installing, FWIW.
I am running Windows 7 64 bit. I realized that my first default 3.5.1 install was 32-bit so I uninstalled. Then I installed Windows x86-64 executable installer. I tried that twice. I switched to version 2.7.11 Windows x86-64 MSI installer. I still get this error. On the latest try (2.7.11), I ran Dependency Walker and got 3 errors:
Error: At least one required implicit or forwarded dependency was not found.
Error: At least one module has an unresolved import due to a missing export function in an implicitly dependent module.
Error: Modules with different CPU types were found.
The first error is that python27.dll is missing. I found that in the System folder and copied it into the main folder of my install (C:\Python27) and then also tried the DLL folder. Still getting my same error. Pulling me hair out and it doesn't help that I am brand new to python in general! I am worried that the uninstalls haven't been scrubbing properly or I have otherwise messed this up.
Thanks and sorry!
Related
Very weird problem. While python and works perfectly fine, I couldn't use pipenv.
I'm running it on windows, and it doesn't work on windows terminal, powershell, vscode terminal. Python version is 3.10.5, system PATH already has the folder location where python.exe is. I have also tried adding PYTHONPATH and PYTHONHOME variables but still did not work.
I'm still new at this, I tried pip uninstall pipenv, virtualenv, but when I run pipenv it still gives me the same error message and not the "not recognized as a command" error.
This is the error message when I run pipenv --version, pipenv shell, pipenv install etc.:
Could not find platform independent libraries <prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Python path configuration:
PYTHONHOME = (not set)
PYTHONPATH = (not set)
program name = 'c:/program files/inkscape/bin/python.exe'
isolated = 0
environment = 1
user site = 1
import site = 1
sys._base_executable = 'C:\\program files\\inkscape\\bin\\python.exe'
sys.base_prefix = 'D:\\a\\_temp\\msys\\msys64\\mingw64'
sys.base_exec_prefix = 'C:\\program files\\inkscape'
sys.executable = 'C:\\program files\\inkscape\\bin\\python.exe'
sys.prefix = 'D:\\a\\_temp\\msys\\msys64\\mingw64'
sys.exec_prefix = 'C:\\program files\\inkscape'
sys.path = [
'D:\\a\\_temp\\msys\\msys64\\mingw64\\lib\\python38.zip',
'D:\\a\\_temp\\msys\\msys64\\mingw64\\lib\\python3.8',
'D:\\a\\_temp\\msys\\msys64\\mingw64\\lib\\python3.8',
'C:\\program files\\inkscape\\lib\\python3.8\\lib-dynload',
]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'
Current thread 0x00006e4c (most recent call first):
<no Python frame>
I thought inkscape was the problem, so I uninstalled it, but it still doesn't work.
Please help me, thank you
I may not be able to answer your question but I might contribute to the solution:
1.try to find here why you get the ModuleNotFoundError: No module named 'encodings'
what library are you missing ?
2. Check this older thread here it may be of help : ImportError: No module named 'encodings'
3. I used to use Pipenv in my Jupiter terminal and due to colleagues engineering choices I always had problem so decided to move to Poetry check it out is really good :https://python-poetry.org/
I may have not helped you find the answer but hopefully have made a small contribution...all debugging is like criminal investigation sometimes you need to incrementally acquire new evidence to solve crimes so ..expect lots of patience from yourself and don't get disappointed easily!
This was the answer for me:
Long story short, I uninstalled the python from Microsoft Store, restarted my computer, installed using the python 3.10.5 installer from python.org, made sure I check the checkbox to “add python to PATH”, restart my computer. On the terminal, run “which python” and ensure it is on the right path, which should be “c:\users\ [username]\appdata\local\programs\python\python310\python” and not on “c:\program files\windowsapp....” This should be both on the user variable and system variable for the variable “PATH”
I consulted with a programmer friend and he helped me solve this issue.
This is the process for troubleshooting for anyone facing similar issues as I did on Windows:
Find which python, pip, and pipenv the system is using (different terminals like windows terminal, powershell, cmd prompt might have different results, so just use the one you like the most, which was for me was my modified windows terminal). The error code here only tells me the symptoms and not the actual problem. So pursuing the “encoding module not found” was actually jumping deeper into the rabbit hole. Luckily, I realized from experience that encoding was not the issue, but rather the terminal did not recognize where python or pipenv is. (I do realize that when a module or cmd is not recognized, the terminal will usually say “module not recognized” instead of the this long error prompt. So it is still a mistery to me why it did that instead of the simple “module not recognized”.
“Which python” shows the default python installation used, “python -V” shows which python it is associated with and the location, “pip show certifi” is for showing which python pip is using
I found a discrepancy, where most of my modules use appdata, which is where normally pip installs and python.org installers use. But python was using WindowsApp because I had installed it using microsoft store. (On my defense, when you google python installer most guides will tell you to install from microsoft store, which was a rookie mistake)
Uninstall the python you don’t want on “add or remove program” from windows. Then install python on its website and make sure to check the checkbox for adding the newly installed python to the system environment variable. See if it works on the terminal. Normally the computer needs to reboot to make the necessary changes.
Done! If it doesn’t work, make sure to purge every python you have on the computer, install using the installer directly from the python website, and make sure the python path is added to the environment variable
When pip install pybullet is entered into the command prompt, the wheel fails to build and “errors out with exit status 1” then after a long list of red text it says: LINK : fatal error LNK1181: cannot open input file ‘Ws2_32.lib’ before trying and failing to build the wheel again with the same error. What does this mean and how can I fix it?
My first problems were the same as the ones in this question but I resolved those by adding the file locations to the path. I was going to try the same solution with this problem but I could not find Ws2_32 on the computer. I think this has something to do with it being an input file. There are several files named WS2_32 (where the s is capitalized) that are in similar places to the other files I needed to add to PATH but adding them to the path or LIB does not change anything. I have tried most of the solutions I have found online, though there are not many. I just do not know how to make sure the computer can find a file that I can’t. Does this mean I just don’t have it? Is there anywhere I can download it? I have also restarted the computer several times.
I have installed pybullet successfully on another computer and I have tried to make my Visual Studio installation look similar (pybullet requires Visual Studio).
I am using Python 3.6 64bit, Pip is upgraded, and Windows 7. The only difference that I think might matter between the two computers is that the successful one runs Windows 10. I can provide more information if it is needed. Thanks for the help.
I installed pybullet in VS Code without wheel installed and it gets installed successfully.
Maybe try installing it without using wheel.
I have a GUI application made using PySide2 and it some major modules it uses are OpenVino(2019), dlib, OpenCV-contrib(4.2.x) and Postgres(psycopg2) and I am trying to freeze the application using PyInstaller (--debug is True).
The program gets frozen without errors but during execution, I get the following error:
Fatal Python error: initfsencoding: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'
after which the application exits.
I have tried many suggestions provided in other stackoverflow questions/github issues but none of them have worked.
I have python version 3.7.6 but I have also tried with 3.6.8 (both local installation and after creating new venv in pycharm). I have tried different versions of pycharm as well(it shows som other errors below 3.5). I have tried pycharm 3.6 both develop branch and master branch.
I have checked my PYTHONPATH and PYTHONHOME in env variables, they are pointing to python's location.
I have modified my specfile to include the necessary binaries, files, imports and folders. I would share it if needed. Also any other logs during build or execution.
I would like to know what I should do to solve this, wheather this issue is because of some component or is this a PyInstaller issue, and if so, should I raise it on github.
My os is windows 10.
You changed the python version. So, you have to give a new path according to the Python version.
Just remove all older version and the current one and reinstall new Python v.3.8.1
You need to include base_library.zip in your application folder
I have been trying to get SCons working now for quite a time, but didn't succeed yet. Before everything else: I'm running Windows 7 x64.
I have firstly installed Python 2.7.11 in C:\Software\Python27 and added both that directory as C:\Software\Python\Scripts to
the system path (for all users, that is). Then I installed SCons in C:\Software\Python27\Lib\site-packages\scons-2.4.1, and
the scripts in the previous mentioned scripts-directory (the directories which the SCons installation msi defaults to).
And now when I try to run SCons I get this error message:
Import failed. Unable to find SCons files in:
...
ImportError: No module named SCons.Script
As a user I really don't have any idea where the error comes from, other than that SCons can't resolve it's own imports.
I got it working by creating though by creating a new folder: C:\Software\Python27\Scripts\scons-local and moving the
contents of the SCons installation folder (...\Python27\Lib\site-packages\scons-2.4.1) to the newly created folder. But this
gives me a syntax error:
I found here that this error is due to my Python version not supporting conditional expressions, because this kind of
expressions are supported from Python 2.4 and higher. The thing is though that I am using Python 2.7.11, and thus I shouldn't get
this error.
Some help would be highly appreciated, thanks in advance!
The windows installer is no longer supported.
The best way to install SCons is now via pip
so:
python -Mpip install SCons
Note you will need Python 3.5 or newer (though at this point I'd suggest 3.10 or newer)
I have this issue where I try to import cv2 on Python and get the following error message.
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: DLL load failed: %1 is not a valid Win32 application.
I do understand there are many posts about this where it is suggested that the bitness of the package is different from the Python package.
However, everything I am running is 64 bits. I am on Windows 7 64 bits, I have the winpython 2.7.3.3, 64 bits distribution, and I compiled OpenCV in 64 bits with the instruction provided here and placed the cv2.pyd DLL file in the Lib/site-packages folder of the Python interpreter.
Unfortunately, the suggestion of using the 32 bits version of Python isn't working for me any more as I have to handle NumPy arrays too large for 32 bits.
The only thing missing was to add the new NumPy binaries path (C:\opencv\build\bin\Release) to the Windows PATH environment variable, restart the Python interpreter.
Everything seems to be working fine now!
The ImportError message is a bit misleading because of the reference to Win32, whereas the problem was simply the OpenCV DLLs were not found.
This problem was solved by adding the path the OpenCV binaries to the Windows PATH environment variable (as an example, on my computer this path is: C:\opencv\build\bin\Release).
You could try installing the 32 bit version of OpenCV.
I just hit this and the problem was that the package had at one point been installed in the per-user packages directory. (On Windows.) aka %AppData%\Python. So Python was looking there first, finding an old 32-bit version of the .pyd file, and failing with the listed error. Unfortunately pip uninstall by itself wasn't enough to clean this, and at this time pip 10.0.1 doesn't seem to have a --user parameter for uninstall, only for install.
tl;dr Deleting the old .pyd from %AppData%\python\python27\site-packages resolved this problem for me.
Or you have to rebuild the cv2 module for Windows 64 bit.
This error can also appear when Python versions are mixed:
For example, if any of the DLL file to be loaded has been compiled using Python 2.7.16 and you try to import with Python 2.7.15 the error ImportError: DLL load failed: %1 is not a valid Win32 application. is thrown.
This is at least what I've found to be the problem in my case.
All you have to do is copy the cv2.pyd file from the x86 folder (C:\opencv\build\python\2.7\x86\ for example) to C:\Python27\Lib\site-packages\, not from the x64 folder.
I had the same error as the one mentioned in previous answers, but it happens only when I use pyinstaller.
I did the following in my Poetry venv:
poetry run python -m pip install pypiwin32
And it worked for me. I am using
python 3.8.10
pyinstaller 4.7
# Those are the versions that worked for me
pypiwin32 223
pywin32 303
pywin32-ctypes 0.2.0
When I had this error, it went away after I my computer crashed and restarted. Try closing and reopening your IDE. If that doesn't work, try restarting your computer. I had just installed the libraries at that point without restarting PyCharm when I got this error.
I never closed PyCharm first to test, because my blasted computer keeps crashing randomly... I am working on that one, but it at least it solved this problem... little victories... :).