Ubuntu 'Failed to Import the Site Module' Error Message

Ubuntu 'Failed to import the site module' error message

I couldn't find a solution to this. I decided to upgrade to Ubuntu 17.x and the issues is now gone.

Fatal Python error: init_import_size: Failed to import the site module in Anaconda Prompt

Are you running another python3 set up in your machine ? Because this error occurs when more than one python environment is there. The best solution is to uninstall other python versions set up and do clean installation. Other solutions will be.
a) Check your .bashrc file (if using Ubuntu) and remove the PATH variables to other python versions and only keep the PATH variable for Anaconda.

b) Run the python scripts specific python binary.

/home/username/Programs/anaconda3/bin/python3 file.py

I hope, these solutions will work

Pyinstaller failed to import the site module

Something is amiss with your Python installation. The "site-specific configuration hook" site.py is normally found in the Lib folder just underneath the Python install directory. But according to your error log, PyInstaller finds it in Lib/site-packages.

See also this answer from 2014:

If you have a site.py in site-packages then that is an error, there should be no such file there.

It's referring to Python 2.7, but explains well what site.py does and still applies to newer Python versions, such as Python 3.9 here.

Furthermore, the code line

f = io.TextIOWrapper(io.open_code(fullname), encoding="locale")

in your custom site.py is wrong. There is no (standard) encoding with the name 'locale'. Which is why it raises that LookupError. That same line of code in the site.py included with Python 3.9 does not use the optional encoding argument.

Unable to import a module that is definitely installed

In my case, it is permission problem. The package was somehow installed with root rw permission only, other user just cannot rw to it!

Python error ImportError: No module named

Based on your comments to orip's post, I guess this is what happened:

  1. You edited __init__.py on windows.
  2. The windows editor added something non-printing, perhaps a carriage-return (end-of-line in Windows is CR/LF; in unix it is LF only), or perhaps a CTRL-Z (windows end-of-file).
  3. You used WinSCP to copy the file to your unix box.
  4. WinSCP thought: "This has something that's not basic text; I'll put a .bin extension to indicate binary data."
  5. The missing __init__.py (now called __init__.py.bin) means python doesn't understand toolkit as a package.
  6. You create __init__.py in the appropriate directory and everything works... ?

Python 3.6 and pip install errors on Ubuntu

Try installing the one recommended on Pypi

pip3 install scikit-learn

And if that doesn't work just download the package from here

https://pypi.python.org/pypi/scikit-learn/0.15.2

Linux - Weird Python Output

Assuming you are using ubuntu, here is the relevant bug report https://bugs.launchpad.net/ubuntu/+source/python3.3/+bug/1192890

You need to patch your /etc/bash.bashrc. See comment #6 for details



Related Topics



Leave a reply



Submit