Error Loading Python 3.4 - python

My laptop is installed with Windows 7 64-bit operating system.
Prior to the installation of Python 3.4 using installation file "python-3.4.0.amd64.msi" (downloaded from https://www.python.org/downloads/release/python-340/), I have been using Python 2.7. However, I still need Python 2.7 for ABAQUS and hence need to retain it.
After I installed Python 3.4 and added its path to the environmental variables there was a conflict in calling "python" from command prompt. So I re-named python.exe in Python27 and Python34 folder as python27.exe and python34.exe, respectively. Also I added 27 and 34 as suffix to various other files in scripts folder in both version. I doubt if this is the best way to go forward in retaining two versions at the same time. So this is one question for which I would like an answer or a suitable reference.
But after installation of Python 3.4 I am not able to load python.exe, neither directly from folder nor command prompt. I get the following error:
Fatal Python error: Py_Initialize: unable to load the file system codec
Traceback (most recent call last):
File "C:\Python34\Lib\encodings\__init__.py", line 31, in <module>
ImportError: No module named 'codecs'
I am not able to uninstall the Python 3.4 from the control panel too. I get the following error when I attempt it:
I also tried removing the folder and installing the setup again. But still I get the same error.
I would be glad if some of the Python experts to help me resolve this problem.

Related

What environment variables need to be changed on Windows 10 with install of new Python 3 version to call version I want?

On a Windows 10 machine, I have two versions of Python 3. First, I have 3.7.2 installed with QGIS. There is also a version 2.7 with QGIS, but I haven't used that at all. I was using 3.7 as my default Python when I did a few things in Python and I could call that with python3. Now, I'm using Python more and I need a newer version because of package needs. I got the official 3.9.6 from python.org and it seemed to install fine. (I'm also trying to get used to pipenv, but I haven't quite figured all of the virtual environment thing out yet. Just mentioning that, I don't think that's the real problem for me.)
Whether I use pipenv or call py -3.9 (found this command here) on a command prompt, I get this error message:
C:\Users\jp>py -3.9
Error processing line 1 of C:\OSGeo4W64\apps\Python37\lib\site-packages\matplotlib-3.1.3-py3.7-nspkg.pth:
Traceback (most recent call last):
File "C:\OSGeo4W64\apps\Python37\lib\site.py", line 168, in addpackage
exec(line)
File "", line 1, in
File "C:\OSGeo4W64\apps\Python37\lib\importlib_init_.py", line 51, in
_w_long = _bootstrap_external._w_long
AttributeError: module 'importlib._bootstrap_external' has no attribute '_w_long'
I tried calling python3 on the cmd and that caused a Bing window to open and take me to the Microsoft Store to download Python 3.
I changed the PATH setting on the computer. I thought I had the environment taken care of, but apparently not. Something is eluding me and I don't know what setting I need to change. I did have "C:\OSGeo4W64" on my PATH, but I took that out. I've logged out and back in for the changes to take effect. What else do I need to change so that calling python3 just looks in C:\Program Files\Python39?
I'm assuming you aren't using C:\program files\python39 for OSGeo4 work. I've had the best luck on Windows 10 installing python from the Microsoft store. That version comes pre-configured with a shortcut to a terminal with all the correct variables set.
It's mainly that OSGeo4W64 is on your PATH either before or instead of your desired python location. I wouldn't advise just adding it to your user's PATH because it may break OSGeo in weird ways (small chance).
Maybe "python launcher" has been installed. You can try that. Otherwise, here's the setup guide. https://docs.python.org/3.9/using/windows.html

How do I fix python 3.8.5. error "ImportError: cannot import name 'open_code' from 'io' (unknown location)"

I'm a complete novice as far as python is concerned, but need to install it for PlatformIO. I installed python-3.8.5-amd64.exe on Windows 10 and installed PlatformIO in VSCode. But when I try to do a build I get:
Fatal Python error: init_sys_streams: can't initialize sys standard streams
Traceback (most recent call last):
File "C:\Program Files\Python38\lib\io.py", line 54, in <module>
ImportError: cannot import name 'open_code' from 'io' (unknown location)
Since io.py is installed as part of the python installation, I assume the 'open_code' symbol should be installed. Running the Repair option from python-3.8.5-amd64.exe and rebooting claims everything's fine, but it still fails.
Can someone explain, in simple terms, what I need to do to fix this?
Note: there's an answer here which indicates it's due to there having been 2 versions of python installed and that something's pointing at the wrong verison, but it doesn't explain how to fix it in any way that I understand (as well as being for a Linux installation).
Thanks.
The solution was to delete the .platformio folder from my user folder. Obviously, PlatformIO was 'remembering' the previous python install and confusing things!
this happened to me when multiple versions of Python was installed , and the PATH environment variable had a python path whose version was different from what i was executing. Adjusted the path variable to demote the unused python version and promote the currently used version and it solved the problem.thanks!

Executable made with pyinstaller experiences "Fatal python error: initfsencoding"

I am able to run my python (python 3.7) program on my pc from sublime text. The program uses tkinter and sqlite3. Does pyinstaller not support them?
The error I'm getting when running it (by simply double-clicking the file created in dist:
Fatal Python error: initfsencoding: unable to load the file system codec
zipimport.ZipImportError: can't find module 'encodings'
If anyone has some experience with this all help will be greatly appreciated!
I can post the code if the issue might be in the code itself.
You are using python 3.7. As far as I have tested , modules like pyinstaller don't seem to be working in this version. Try uninstalling your python (don't forget to backup your files before), and installing python 3.6.3 or any other python 3 version except python 3.7. Same happened with me and I did this. It worked.

Problems setting up Python

I recently installed python 3.3.2
Im trying to install NumPy, when I call import NumPy from the command line I get the following error:
import numpy
Traceback (most recent call last):
File "<console>", line 1, in <module>
ImportError: No module named 'numpy'
From what I've read it may have to do with having multiple version of Python installed.
The only problem is when I try run the Which Python command I get another error?
which python
File "<console>", line 1
which python
^
SyntaxError: invalid syntax
Any Ideas?
Thanks
What you have to do depends on the operating system you are using. I'me assuming you are using Linux. If you are using Linux with some kind of package manager, you should use a numpy package that is expressly for the python version you want to us it with. The same goes if you are using windows.
Note that you can have different versions of python installed, but in general only one is symlinked to python. Running ls -l /usr/local/bin/python should tell you what is the default version on your machine. If you have multiple versions, there should also be programs named python2 and python3. Using ls -l /usr/local/bin/python2 and ls -l /usr/local/bin/python3 will show you the which versions you really have.
On linux and other UNIX-like systems, you can usually find Python's files in a subdirectory of /usr/local/lib. For python 2.7 this will be /usr/local/lib/python2.7, for 3.2 it will be /usr/local/lib/python3.3. These directories will have a subdirectory site-packages. In those site-packages you should look for a subdirectory numpy. If you find /usr/local/lib/python2.7/site-packages/numpy but not /usr/local/lib/python3.3/site-packages/numpy, then numpy was not installed for 3.2.
Edit: In Windows, Python usually installs itself in the root of the C: drive, like C:\Python27 or C:\Python33. I don't have a windows machine handy, but there should be a site-packages subdirectory in both of them as well. Look for the numpy subdirectory in there.
For windows, you can find precompiled binaries for mumpy here. You just need to know is you have a 32 bit (win32) or 64 bit version (amd64) of windows. E.g. for python 3.3 and 2 32-bit windows I would suggest numpy-MKL-1.7.1.win32-py3.3.‌exe.
Type open a command prompt and type python It will then tell you what version you are running as it opens the interactive python editor.
Otherwise get your numpy from here These are compiled binaries and should be the most straightforward to install for a windows user

Understanding concepts of Python installation on Mac OS for Cocoa development

I want to try to develop Cocoa application using Python. I'm new to Mac and I need some help to understand how it works.
First of all I found that I need to install py2app and py2objc. I used easy_install as documented here. There were a few errors with setup tools but eventually py2app was installed. Then I launch "easy_install pyobjc==2.2" and it ended with many errors:
Processing pyobjc-2.2-py2.7.egg
...
Running pyobjc-framework-SystemConfiguration-2.2/setup.py -q bdist_egg --dist-dir /tmp/easy_install-ipMzFU/pyobjc-framework-SystemConfiguration-2.2/egg-dist-tmp-odfVol
In file included from Modules/_manual.m:1:
/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:19:20: error: limits.h: No such file or directory
/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:22:2: error: #error "Something's broken. UCHAR_MAX should be defined in limits.h."
/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:26:2: error: #error "Python's source code assumes C's unsigned char is an 8-bit type."
/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:33:19: error: stdio.h: No such file or directory
/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:35:5: error: #error "Python.h requires that stdio.h define NULL."
/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:38:20: error: string.h: No such file or directory
/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:40:19: error: errno.h: No such file or directory
/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:42:20: error: stdlib.h: No such file or directory
/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:44:20: error: unistd.h: No such file or directory
/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:56:20: error: assert.h: No such file or directory
...
etc
My questions:
What I need to do to install
py2objc? Unfortunately, I haven't
found a solution for errors, which I
posted previously.
As I understand
there are two kinds of python. One I
installed into Applications folder
(IDLE, launcher), another is the
current Python version supplied with
OS. Can you describe the
difference?
How can I select the
current version of Python used by
Mac OS? And what is the Current
folder in
/Library/Frameworks/Python.framework?
Probably it looks confusing, but this is my first steps! :)
Thank you
Cannot give a definitive answer to that. See comment.
You can install multiple versions of python on your machine (OSX includes a defualt one as you already mentioned). In the applications folder there are some apps to open an interactive interpreter in which you can enter python commands, such as IDLE. These applications use one of the python versions you've got installed. Which brings us to
python_select is the command you want. e.g. python_select -l to list all the python versions you've got installed and python_select python27 to select your own 2.7 version. The Current folder links to the version currently selected via python_select

Categories