Installation Failure in python - python

I had a problem trying to install TensorFlow. After multiple unsuccessful attempts, I uninstalled everything related to python.
Now, when I try to install python with
pip install python
I got the following error related to the path:
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'
Current thread 0x00007fffa1d233c0 (most recent call first):
Abort trap: 6

Probably you can't install Python via pip, because you may have deleted pip together with Python. Try to install Python from the official Python website: https://www.python.org/downloads/

Related

Can't install dbt-snowflake; "No module named 'cmake'"

(Context: Barely a novice at Terminal, know some SQL, don't know Python)
I'm taking a course on dbt, have my own Snowflake set up, and I'm trying to install dbt-snowflake on Mac. Attempting to run:
pip install dbt-snowflake
This fails, and it returns:
`
Traceback (most recent call last):
File "/Users/xxxx/course/venv/bin/cmake", line 5, in <module>
from cmake import cmake
ModuleNotFoundError: No module named 'cmake'
error: command '/Users/xxxx/course/venv/bin/cmake' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for pyarrow
Failed to build pyarrow
ERROR: Could not build wheels for pyarrow, which is required to install pyproject.toml-based projects
`
I once successfully changed Python version in virtual environment to 3.9 to see whether that was the problem (but I can't replicate how I changed it), that didn't solve the problem, and currently it's back to 3.11.
Have installed multiple versions of snowflake (3.7, 3.9, 3.11). I don't really understand how this works in context of everything.
I have tried deleting and recreating virtual environments (under same name, venv)
uninstalled and reinstalled cmake (pip install --upgrade cmake); this is version 3.25.0
I don't understand how I can have cmake installed and be told there is no module named 'cmake'.
Is there a particular version of Python I should be running, and if so, how do I reliably change that in virtual environments and different directories?
EDIT TO ADDRESS A COMMENT: I installed Python versions via terminal brew install python#3.9

Python3 not working in Ubuntu after accidetaly deleting usr/lib/ files

I'm using Ubuntu 16.04 LTS, I recently accidentaly deleted some files and folders
( /urs/lib/pyhon3.x ), after this Python3 is not working.
python3 gives the following error message.
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Current thread 0x00007f7e77307700 (most recent call first):
Aborted (core dumped)
I have tried re-installing python3 by
sudo apt-get install python3
Still, the problem persists, I have tried unset PYTHONHOME and unset PYTHONPATH.
But nothing is working, how can we make this work?
Update(1) pip is not working as python is not working.
pip install encodings returns the following error,
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Current thread 0x00007f76e2667700 (most recent call first):
Aborted (core dumped
Update (2) :
I have tried
sudo apt-get --purge autoremove python3 then rebooot then, sudo apt install python3,
it gives the following error,
Reading package lists... Done
Building dependency tree
Reading state information... Done
python3 is already the newest version (3.5.1-3).
0 upgraded, 0 newly installed, 0 to remove and 54 not upgraded.
2 not fully installed or removed.
Need to get 0 B/8 710 B of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
[master ccedc09] saving uncommitted changes in /etc prior to apt run
Author: rajgourav <rajgourav#euclide.ipcms1.ipcms.unistra.fr>
8 files changed, 4 insertions(+), 4 deletions(-)
Setting up python3.5 (3.5.2-2ubuntu0~16.04.12) ...
Could not find platform independent libraries <prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Current thread 0x00007efddc85f700 (most recent call first):
Aborted (core dumped)
dpkg: error processing package python3.5 (--configure):
subprocess installed post-installation script returned error exit status 134
dpkg: dependency problems prevent configuration of python3:
python3 depends on python3.5 (>= 3.5.1-2~); however:
Package python3.5 is not configured yet.
dpkg: error processing package python3 (--configure):
dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup erro
r from a previous failure.
Errors were encountered while processing:
python3.5
python3
I removed python3 from my ubuntu(18.0.4.5) to see if i can reproduce
the same problem.
It seems that removing python and configuration files by
sudo apt-get --purge autoremove python3
sudo reboot
then
sudo apt install python3
works
Have you tried to install the module encodings with pip install encodings ?
Else, try to reconfigure Python3 with dpkg using the command sudo dpkg-reconfigure python3

python unistallation gone wrong, apt-get and dpkg broken error message 1 on Ubuntu

The title says it all in short. I tried to purge all of my python installations as they were a mess. Turned out I broke everything and was not able to install or uninstall anything with apt-get or dpkg, only got the following error message (or similar) various times:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
libexpat1-dev libpython3.7 libpython3.7-dev libpython3.7-minimal libpython3.7-stdlib libpython3.8
libpython3.8-dev libpython3.8-minimal libpython3.8-stdlib zlib1g-dev
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
python3
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
2 not fully installed or removed.
After this operation, 191 kB disk space will be freed.
Do you want to continue? [Y/n] Y
dpkg: error processing package python3 (--remove):
package is in a very bad inconsistent state; you should
reinstall it before attempting a removal
Errors were encountered while processing:
python3
E: Sub-process /usr/bin/dpkg returned an error code (1)
What sudo dpkg --audit currently gives me is:
sudo dpkg --audit
The following packages are only half configured, probably due to problems
configuring them the first time. The configuration should be retried using
dpkg --configure <package> or the configure menu option in dselect:
python3-lib2to3 Interactive high-level object-oriented language (2to3, ve
python3-minimal minimal subset of the Python language (default python3 ve
The following packages are missing the list control file in the
database, they need to be reinstalled:
libpython3-stdlib:amd64 interactive high-level object-oriented language (default
libpython3.6:amd64 Shared Python runtime library (version 3.6)
libpython3.6-minimal:amd64 Minimal subset of the Python language (version 3.6)
libpython3.6-stdlib:amd64 Interactive high-level object-oriented language (standard
libpython3.7:amd64 Shared Python runtime library (version 3.7)
libpython3.7-dev:amd64 Header files and a static library for Python (v3.7)
libpython3.7-minimal:amd64 Minimal subset of the Python language (version 3.7)
libpython3.7-stdlib:amd64 Interactive high-level object-oriented language (standard
libpython3.8:amd64 Shared Python runtime library (version 3.8)
libpython3.8-dev:amd64 Header files and a static library for Python (v3.8)
libpython3.8-minimal:amd64 Minimal subset of the Python language (version 3.8)
libpython3.8-stdlib:amd64 Interactive high-level object-oriented language (standard
python3.6 Interactive high-level object-oriented language (version
python3.6-minimal Minimal subset of the Python language (version 3.6)
The following packages are missing the md5sums control file in the
database, they need to be reinstalled:
libpython3-stdlib:amd64 interactive high-level object-oriented language (default
libpython3.6:amd64 Shared Python runtime library (version 3.6)
libpython3.6-minimal:amd64 Minimal subset of the Python language (version 3.6)
libpython3.6-stdlib:amd64 Interactive high-level object-oriented language (standard
libpython3.7:amd64 Shared Python runtime library (version 3.7)
libpython3.7-dev:amd64 Header files and a static library for Python (v3.7)
libpython3.7-minimal:amd64 Minimal subset of the Python language (version 3.7)
libpython3.7-stdlib:amd64 Interactive high-level object-oriented language (standard
libpython3.8:amd64 Shared Python runtime library (version 3.8)
libpython3.8-dev:amd64 Header files and a static library for Python (v3.8)
libpython3.8-minimal:amd64 Minimal subset of the Python language (version 3.8)
libpython3.8-stdlib:amd64 Interactive high-level object-oriented language (standard
python3.6 Interactive high-level object-oriented language (version
python3.6-minimal Minimal subset of the Python language (version 3.6)
Using sudo dpkg --configure on both python3-minimal and python3-lib2to3 gives me the following:
Setting up python3-minimal (3.6.7-1~18.04) ...
Could not find platform independent libraries <prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ModuleNotFoundError: No module named 'encodings'
Current thread 0x00007fa5074f0740 (most recent call first):
Aborted (core dumped)
dpkg: error processing package python3-minimal (--configure):
installed python3-minimal package post-installation script subprocess returned error exit status 134
Errors were encountered while processing:
python3-minimal
$ sudo dpkg --configure python3-lib2to3
Setting up python3-lib2to3 (3.6.9-1~18.04) ...
Could not find platform independent libraries <prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ModuleNotFoundError: No module named 'encodings'
Current thread 0x00007f439a7a0740 (most recent call first):
Aborted (core dumped)
dpkg: error processing package python3-lib2to3 (--configure):
installed python3-lib2to3 package post-installation script subprocess returned error exit status 134
Errors were encountered while processing:
python3-lib2to3```
I have tried everything found [here][1], and have no idea what to try next. Anyone run into such a mess of a package removal before?
[1]: https://phoenixnap.com/kb/fix-sub-process-usr-bin-dpkg-returned-error-code-1
Have you tried --remove --force ?

importing pycurl with libcurl4 raises ImportError

I am using Ubuntu 18.04. If I install libcurl4 (instead of libcurl3), when I import pycurl installed with pipenv I get
>>> import pycurl
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: /usr/lib/x86_64-linux-gnu/libcurl.so.4: version `CURL_OPENSSL_3' not found (required by /home/pietro/envs/try_fabric-kcbGLH3z/lib/python3.6/site-packages/pycurl.cpython-36m-x86_64-linux-gnu.so)
Note that this error is raised only when I use a pycurl installed with pipenv or pip. If I use instead pycurl installed through apt on system python there are any errors...
What can I do to avoid this impasse?
I assume you upgraded your operating system recently.
pip stores a cache of built wheels in your home directory, when upgrading your os it is a good idea to clear this cache as the binaries may now link against incompatible system libraries
You can do this by rm -rf ~/.cache/pip and then recreate your environment

CNTK Crashes Python when imported : Fatal Python error: Py_Initialize: can't initialize sys standard streams

I have installed CNTK CPU only version module using pip
pip3 install https://cntk.ai/PythonWheel/CPU-Only/cntk-2.3.1-cp36-cp36m-win_amd64.whl
When i imported in spyder IDE, it was working fine. But when i tried to install other modules likes pandas, numpy using pip it crashes Python and says stopped working.
C:\Program Files\Python36\Scripts>pip3 install pandas
Fatal Python error: Py_Initialize: can't initialize sys standard streams
Traceback (most recent call last):
File "C:\Program Files\Python36\Lib\site-packages\cntk\io\__init__.py", line 1
3, in <module>
ModuleNotFoundError: No module named 'cntk'
It says There is no module names CNTK and crashes Python. I am unable to open Python IDE after this.
Any idea why this happens? I uninstalled and installed for nearly 4 times. It still a problem.

Categories

Resources