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
insite-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:
- You edited
__init__.py
on windows. - 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).
- You used WinSCP to copy the file to your unix box.
- WinSCP thought: "This has something that's not basic text; I'll put a .bin extension to indicate binary data."
- The missing
__init__.py
(now called__init__.py.bin
) means python doesn't understand toolkit as a package. - 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
Change Parent Shell's Environment from a Subprocess
Docker.Errors.Dockerexception: Error While Fetching Server API Version
Print List Without Brackets in a Single Row
Convert Base-2 Binary Number String to Int
Understanding Dict.Copy() - Shallow or Deep
Extracting Extension from Filename in Python
How to Make Firefox Headless Programmatically in Selenium with Python
Why Does Python Code Run Faster in a Function
Accessing Elements of Python Dictionary by Index
Disable Webcam's Autofocus in Linux
Differencebetween "Is None" and "== None"
Element-Wise Addition of 2 Lists
Generate Random Integers Between 0 and 9
What's the Difference Between a Python Module and a Python Package
Matplotlib Scatterplot; Color as a Function of a Third Variable