Python platform independent libraries

Could not find platform independent libraries <prefix&gt

Because the new python is in /usr/lib/local and the system is looking in /usr/lib/. The specific error I got after deleting system python libraries was: To fix this replace the system python with your newly installed python ( I did the first two earlier PYTHONHOME is used for standard python libraries.

Could not find platform independent libraries <prefix&gt

My travis job hit issue of following:

Process Output:Could not find platform independent libraries Process Output:Could not find platform dependent libraries Process Output:Consider setting $PYTHONHOME to [:] Process Output:Fatal Python error: Py_Initialize: Unable to get the locale encoding Process Output:ModuleNotFoundError: No module named 'encodings' 

I have already tried to set PYTHONPATH and pythonhome, but still doesn’t work. Could anyone help me on that ? Thanks

export PYTHONHOME='$HOME/miniconda' export PYTHONPATH='$HOME/miniconda:$PYTHONPATH' 

This happens when you remove the default python libraries and don’t replace it. For example when following upgrade instructions that are less than complete. I ran into this and solved it like this on ubuntu ( should be similar process on others ).

Читайте также:  Убрать наследование стилей css

I installed new python using ( overuse of sudo I know ):

$ sudo apt-get update $ sudo apt-get install build-essential checkinstall $ sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev $ cd /usr/src $ sudo wget https://www.python.org/ftp/python/2.7.13/Python-2.7.13.tgz $ sudo tar xzf Python-2.7.13.tgz $ cd Python-2.7.13 $ sudo ./configure $ sudo make install 

This created a python2.7 for me in /usr/local/lib and /usr/local/bin. I then deleted the system python in /usr/lib/ thinking I don’t want two versions and things broke. Because the new python is in /usr/lib/local and the system is looking in /usr/lib/.

$ cd /usr/lib $ sudo rm -rf python2.7 

The specific error I got after deleting system python libraries was:

$ sudo apt-get install python-httplib2 Reading package lists. Done Building dependency tree Reading state information. Done python-httplib2 is already the newest version (0.8-2build1). 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 1 not fully installed or removed. After this operation, 0 B of additional disk space will be used. Do you want to continue? [Y/n] y Setting up python-httplib2 (0.8-2build1) . Could not find platform independent libraries Could not find platform dependent libraries Consider setting $PYTHONHOME to [:] ImportError: No module named site dpkg: error processing package python-httplib2 (--configure): subprocess installed post-installation script returned error exit status 1 Errors were encountered while processing: python-httplib2 E: Sub-process /usr/bin/dpkg returned an error code (1) 

To fix this replace the system python with your newly installed python ( I did the first two earlier but I want to show a proper python swap here ):

$ cd /usr/lib $ sudo rm -rf python2.7 $ sudo ln -s /usr/local/lib/python2.7 python2.7 $ cd /usr/bin $ sudo rm python2.7 $ sudo ln -s /usr/local/bin/python python2.7 
$ sudo apt-get install python-httplib2 Reading package lists. Done Building dependency tree Reading state information. Done python-httplib2 is already the newest version (0.8-2build1). 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 1 not fully installed or removed. After this operation, 0 B of additional disk space will be used. Do you want to continue? [Y/n] y Setting up python-httplib2 (0.8-2build1) . 

How to troubleshoot «Could not find platform, Stack Overflow Public questions & answers; Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers; Talent Build your employer brand ; Advertising Reach developers & technologists worldwide; About the company

How to troubleshoot «Could not find platform independent libraries <prefix>» in Python & buildozer

Through buildozer in Ubuntu, I was running an app I am developing.
However, I faced the following error:

Could not find platform independent libraries Consider setting $PYTHONHOME to [:] Fatal Python error: initfsencoding: Unable to get the locale encoding ModuleNotFoundError: No module named 'encodings' 

I searched and searched and searched for an adequate method for treating this particular problem on Google. Then, I found few methods to fix this problem.

For the first attempt, I set: export PYTHONHOME=/usr/local/lib/python3.7 as suggested in the error comments. Unfortunately, the same error appeared even with this change. For the second attempt, I tried to delete virtual environment file and reset it as suggested on the following website: ImportError: No module named ‘encodings’. But, again, I failed to eliminate this error.

I saw that some of the posts on Stackoverflow regarding this issue provide repetitive methods. I am stuck with this issue. I would deeply appreciate it if anyone can be kind enough to shed some light on this. Blessings.

Follow these steps to avoid this

  1. Activate virtualenv by source venv/bin/activate
  2. Set ENV[«PYTHON»] to correct Python path under the virtualenv
  3. Install PyCall by pip install pycall
  4. Open v0.6/PyCall/deps/deps.jl with a text editor and replace const PYTHONHOME = «. » with const PYTHONHOME = «»
  5. Run using PyCall

How can I troubleshoot Python «Could not find platform, Normally, when you receive the error message Could not find platform independent libraries

, the string would be replaced with the actual value of prefix. However, if prefix has an empty value, then you get the rather cryptic messages posted in the question. Usage examplesudo ln -s /usr/local/lib64/python3.8/lib-dynload/ /usr/local/lib/python3.8/lib-dynloadFeedback

Could not find platform independent libraries <prefix&gt

After this operation, 0 B of additional disk space will be used. Get:1 http://us-east-1.ec2.archive.ubuntu.com/ubuntu/ trusty/main python3 amd64 3.4.0-0ubuntu2 [8,666 B] Fetched 8,666 B in 0s (53.3 kB/s) Setting up base-files (7.2ubuntu5.5) . Installing new version of config file /etc/issue . Installing new version of config file /etc/issue.net . Installing new version of config file /etc/lsb-release . Installing new version of config file /etc/os-release . Processing triggers for plymouth-theme-ubuntu-text (0.8.8-0ubuntu17.1) . Could not find platform independent libraries Could not find platform dependent libraries Consider setting $PYTHONHOME to [:] Fatal Python error: Py_Initialize: Unable to get the locale encoding ImportError: No module named 'encodings' Aborted (core dumped) update-initramfs: deferring update (trigger activated) Processing triggers for initramfs-tools (0.103ubuntu4.2) . update-initramfs: Generating /boot/initrd.img-3.13.0-74-generic (Reading database . 126647 files and directories currently installed.) Preparing to unpack . /python3_3.4.0-0ubuntu2_amd64.deb . Could not find platform independent libraries Could not find platform dependent libraries Consider setting $PYTHONHOME to [:] Fatal Python error: Py_Initialize: Unable to get the locale encoding ImportError: No module named 'encodings' Aborted (core dumped) dpkg: warning: subprocess old pre-removal script returned error exit status 134 dpkg: trying script from the new package instead . Could not find platform independent libraries Could not find platform dependent libraries Consider setting $PYTHONHOME to [:] Fatal Python error: Py_Initialize: Unable to get the locale encoding ImportError: No module named 'encodings' Aborted (core dumped) dpkg: error processing archive /var/cache/apt/archives/python3_3.4.0-0ubuntu2_amd64.deb (--unpack): subprocess new pre-removal script returned error exit status 134 Could not find platform independent libraries Could not find platform dependent libraries Consider setting $PYTHONHOME to [:] Fatal Python error: Py_Initialize: Unable to get the locale encoding ImportError: No module named 'encodings' Aborted (core dumped) dpkg: error while cleaning up: subprocess installed post-installation script returned error exit status 134 E: Sub-process /usr/bin/dpkg returned an error code (1) 

The issue is probably due to multiple python installations in your system. You have two variables PYTHONPATH and PYTHONHOME. The py3compile module looks up different resources using these two variables. The PYTHONPATH variable augments the default search path for module files. PYTHONHOME is used for standard python libraries. The format is the same as the shell’s PATH. You need to set these variables as follows:

export PYTHONPATH='/path/to/pythondir:/path/to/pythondir/lib-dynload:/path/to/pythondir/site-packages' export PYTHONHOME='/path/to/pythondir' 

How to resolve libraries issues?, Therefore, I decided to reinstall my Linux — if I knew how fast re-installisation can be, I wouldn’t spend days trying to find the mistake. This manual is self-explanatory, great for «dummies» in Linux. But I learnt a lot. Main thing I learnt: Do not delete anything you do not know what it is or what it does!

Can’t run gdb on ubuntu: Could not find platform independent libraries

Can’t run ‘gdb ./a.out’ or even ‘gdb —help’ without getting:

$ gdb ./a.out Could not find platform independent libraries Could not find platform dependent libraries Consider setting $PYTHONHOME to [:] ImportError: No module named site 

Ubuntu Desktop 12.04 LTS is up to date. Works in ‘root’. I’d rather not hardcode a $PYTHONHOME location. Any hints appreciated. Baffled.

update: when I set $PYTHONHOME I get:

$ PYTHONHOME=/usr/lib/python2.7 gdb ./a.out ImportError: No module named site 

update: I do have python-dev installed for native module creation.

Could you be running into this bug? Do you have python and python-libs installed?

Cross gdb can’t find python, 0. You have to set environment variables: PYTHONPATH=C:\msys64\mingw64\lib\python2.7;C:\msys64\mingw64\lib\python2.7\lib-dynload; PYTHONHOME variable refers to python interpreter: PYTHONHOME=C:\msys64\mingw64\bin\pyhon.exe. I built my own gdb under …

Источник

Python platform independent libraries

Glasshost

Programming Problems Solved

How can I troubleshoot Python «Could not find platform independent libraries «

How can I troubleshoot Python “Could not find platform independent libraries ”

If you encounter the error “Could not find platform independent libraries ” while trying to run a Python script or install a package, it means that Python is unable to locate the required libraries on your system. This error can occur due to various reasons, such as missing dependencies or incorrect installation paths.

Here are some steps you can take to troubleshoot and fix this error:

1. Check Python Version

Ensure that you are running the correct version of Python that the package or script requires. You can check the version of Python installed on your system by running the following command in your terminal:

2. Install Required Dependencies

If you are installing a package, make sure that all the required dependencies are installed. You can check the package documentation for a list of dependencies.

If you are running a script that requires external libraries, ensure that those libraries are installed on your system. You can use pip, the package installer for Python, to install external libraries. For example:

3. Check Installation Paths

Check that the installation paths for Python and the required libraries are correct. If the installation paths are incorrect, Python may not be able to locate the required libraries.

You can check the installation paths in Python using the following commands:

This will print a list of directories where Python looks for modules and packages.

4. Set Environment Variables

If the required libraries are installed in a non-standard location, you can set the environment variables to tell Python where to find them. You can set the environment variables in your terminal or in your Python script.

For example, if you have installed the required libraries in /usr/local/lib/python3.7/site-packages, you can set the PYTHONPATH environment variable to this path using the following command:

export PYTHONPATH=/usr/local/lib/python3.7/site-packages 

Alternatively, you can set the environment variable in your Python script using the following code:

import os os.environ['PYTHONPATH'] = '/usr/local/lib/python3.7/site-packages' 

Conclusion

By following the above steps, you should be able to troubleshoot and fix the “Could not find platform independent libraries ” error in Python. If you continue to encounter issues, it is recommended to consult the package or script documentation or seek help from the Python community.

Источник

Оцените статью