So I was able to install sklearn for python2 but for some reason I having issues with doing the same for python3. I am getting this error:
Traceback (most recent call last):
File "/home/ajshack_pg/sklearn/__check_build/__init__.py", line 44, in <module>
from ._check_build import check_build # noqa
ImportError: /home/ajshack_pg/sklearn/__check_build/_check_build.so: undefined symbol: PyUnicodeUCS4_DecodeUTF8
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/ajshack_pg/sklearn/__init__.py", line 133, in <module>
from . import __check_build
File "/home/ajshack_pg/sklearn/__check_build/__init__.py", line 46, in <module>
raise_build_error(e)
File "/home/ajshack_pg/sklearn/__check_build/__init__.py", line 41, in raise_build_error
%s""" % (e, local_dir, ''.join(dir_content).strip(), msg))
ImportError: /home/ajshack_pg/sklearn/__check_build/_check_build.so: undefined symbol: PyUnicodeUCS4_DecodeUTF8
___________________________________________________________________________
Contents of /home/ajshack_pg/sklearn/__check_build:
setup.py setup.pyc __init__.pyc
_check_build.so __init__.py
___________________________________________________________________________
It seems that scikit-learn has not been built correctly.
If you have installed scikit-learn from source, please do not forget
to build the package before using it: run `python setup.py install` or
`make` in the source directory.
If you have used an installer, please check that it is suited for your
Python version, your operating system and your platform.
I tried to go into the source directory and type in what they say to no avail. Any insight here?
Thanks!
If you installed sklearn from source for Python 2.x, some of its binaries may have persisted if you didn't fully remove all sklearn files. Python 2.x and 3.x are quite incompatible with each other, so this might be a reason why it's failing to build.
A few steps to take:
Consider using a virtualenv for your sklearn projects, especially if you have a lot of different packages or Python versions floating around. It's great for keeping different development environments with different Python packages and libraries isolated. Follow this guide if you don't have it already. When creating your virtualenv, make sure to install it with Python 3.x by using this command when creating your virtualenv:
virtualenv -p python3 envname
If building from source: Redownload the sklearn source for your Python 3 version and place it in your virtualenv. Closely follow all build instructions. That should hopefully give you a clean install of sklearn.
If installing with pip: Activate your virtualenv, then:
pip install -U scikit-learn after installing numpy and scipy.
Related
I don't know much about python and I need help to install a python software.
I am using linux mint 12.8.
Since I have tried many things I think I have several versions of python installed (3.5 and 3.7 I think...).
When I run setup.py install I get:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 7, in <module>
import dbm.gnu as gdbm
File "/home/zach/10_Soft/anaconda3/lib/python3.7/dbm/gnu.py", line 3, in <module>
from _gdbm import *
ModuleNotFoundError: No module named '_gdbm'
I tried to install python3.5-gdbm (which appears to be up to date) and python3.7-gdbm (which is not found).
They both seem to be virtual packages of the same package python3-gdbm. I don't really know what to do with this information however...
Do you know what I should do?
I was able to solve this issue using this command:
sudo cp /usr/lib/python3.5/lib-dynload/_gdbm.cpython-35m-x86_64-linux-gnu.so /usr/lib/python3.7/lib-dynload/_gdbm.cpython-37m-x86_64-linux-gnu.so
While installing the socketio package for python using pip3 install socketio, I got the following results:
ERROR: launchpadlib 1.10.13 requires testresources, which is not installed.
WARNING: The scripts easy_install and easy_install-3.8 are installed in '/home/bill/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed netifaces-0.10.6 setuptools-3.3 socketio-0.2.1
Although I was able to import socketio successfully, pip3 seems corrupted(?).
Specifically, when trying to run anything including pip3, even pip3 by itself in the terminal, I get the same error:
Traceback (most recent call last):
File "/usr/bin/pip3", line 6, in <module>
from pkg_resources import load_entry_point
File "/home/<username>/.local/lib/python3.8/site-packages/pkg_resources.py", line 1479, in <module>
register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider)
AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 144, in apport_excepthook
with os.fdopen(os.open(pr_filename,
FileNotFoundError: [Errno 2] No such file or directory: '/var/crash/_usr_bin_pip3.1000.crash'
Original exception was:
Traceback (most recent call last):
File "/usr/bin/pip3", line 6, in <module>
from pkg_resources import load_entry_point
File "/home/<username>/.local/lib/python3.8/site-packages/pkg_resources.py", line 1479, in <module>
register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider)
AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'
I tried reinstalling pip3 but it didn't help. I migrated from ubuntu to mint thinking it is something buggy with the distribution but same results. I also corrupted ubuntu when I tried to remove python and reinstall it since I couldn't use pip, but, you know what they say, live and learn.
Edit: Nothing on using pip3: module "importlib._bootstrap" has no attribute "SourceFileLoader" works for me.
I am currently using linux mint 20, but I experienced the same problem on ubuntu 20.04 and 20.04.1.
Any ideas would be appreciated!
Perhaps you meant this socketio instead?: https://pypi.org/project/python-socketio
python3 -m pip install python-socketio
The package literally named "socketio" seems like it may simply be old and unsupported1, while "python-socketio" seems alive and developed 2 3
To that end, it's often valuable to take a look at similar packages and also to watch out for typosquatting et al. when installing packages via pip!
Edit: Martijn Peters makes a good point that this is the socketio you are looking for: https://pypi.org/project/python-socketio
Read on if you need a solution for the original one you posted about.
Summary: pip3 install git+https://github.com/allenmcgehee/socketio-0.2.1-patched
I was able to reproduce this in a docker container running ubuntu:20.04 exactly as you described which gave me some hope that I could help out.
I found that socketio had a dependency for setuptools==3.3 which seemed odd to me, but lines up with why the core functionality of pip was breaking after installing socketio.
I am not sure where this package is maintained as there is no git repo referenced. I did find a Russion website in the PKG-INFO, but I wasn't sure where to go from there...
Here is a version of socketio with a requirement of setuptools>=42 so that nothing gets broken: https://github.com/allenmcgehee/socketio-0.2.1-patched
And finally, here is the single command that should install socketio for you without breaking pip:
pip3 install git+https://github.com/allenmcgehee/socketio-0.2.1-patched
**I am assuming you've already fixed pip.
This happened to me with a different module. My solution was to down-grade the version of pip and the version of the module. So, for you the answer would be to run:
python -m pip install pip== (previous version of your pip)
python -m pip uninstall socketio
python -m pip install socketio==0.2.0
I am trying to get VScode to work with anaconda but having issues with numpy. I have managed to get VScode to use the right python environment From VScode (ctrl+shift+P, type Python:Select Interpreter and select the appropriate option).
However, when I type "import numpy" in to my script, I get the following error message:
C:\ProgramData\Anaconda3\envs\sandpit\lib\site-packages\numpy\__init__.py:140: UserWarning: mkl-service package failed to import, therefore Intel(R) MKL initialization ensuring its correct out-of-the box operation under condition when Gnu OpenMP had already been loaded by Python process is not assured. Please install mkl-service package, see http://github.com/IntelPython/mkl-service
from . import _distributor_init
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\envs\sandpit\lib\site-packages\numpy\core\__init__.py", line 24, in <module>
from . import multiarray
File "C:\ProgramData\Anaconda3\envs\sandpit\lib\site-packages\numpy\core\multiarray.py", line 14, in <module>
from . import overrides
File "C:\ProgramData\Anaconda3\envs\sandpit\lib\site-packages\numpy\core\overrides.py", line 7, in <module>
from numpy.core._multiarray_umath import (
ImportError: DLL load failed while importing _multiarray_umath: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\Users\[NAME]\Documents\python\sandpit\hello.py", line 2, in <module>
import numpy
File "C:\ProgramData\Anaconda3\envs\sandpit\lib\site-packages\numpy\__init__.py", line 142, in <module>
from . import core
File "C:\ProgramData\Anaconda3\envs\sandpit\lib\site-packages\numpy\core\__init__.py", line 54, in <module>
raise ImportError(msg)
ImportError:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy c-extensions failed.
- Try uninstalling and reinstalling numpy.
- If you have already done that, then:
1. Check that you expected to use Python3.8 from "C:\ProgramData\Anaconda3\envs\sandpit\python.exe",
and that you have no directories in your PATH or PYTHONPATH that can
interfere with the Python and numpy version "1.18.1" you're trying to use.
2. If (1) looks fine, you can open a new issue at
https://github.com/numpy/numpy/issues. Please include details on:
- how you installed Python
- how you installed numpy
- your operating system
- whether or not you have multiple versions of Python installed
- if you built from source, your compiler versions and ideally a build log
- If you're working with a numpy git repository, try `git clean -xdf`
(removes all files not under version control) and rebuild numpy.
Note: this error has many possible causes, so please don't comment on
an existing issue about this - open a new one instead.
Original error was: DLL load failed while importing _multiarray_umath: The specified module could not be found.
I have successfully called the 'import numpy' command from the anaconda command prompt so it seems the issue is just with VS-Code?
I have also tried to reinstall numpy from the environment with the following command conda install numpy --force-reinstall but this has no effect?
Try launching VS Code from your activated conda environment. Errors like this typically come up if you managed to run code before your shell had a chance to do a conda environment activation.
There is one step more
Launch Anaconda 3 powershell
conda init cmd.exe #to allow cmd to run VScode
Lauch VScode by the hitting the command code.
I get the error
Could not import setuptools which is required to install from a source distribution.
Traceback (most recent call last):
File "/home/comp1/anaconda3/lib/python3.5/site-packages/pip/req/req_install.py", line 387, in setup_py
import setuptools # noqa
File "/home/comp1/anaconda3/lib/python3.5/site-packages/setuptools/__init__.py", line 10, in <module>
from setuptools.extern.six.moves import filter, filterfalse, map
ImportError: No module named 'setuptools.extern.six'
even though the same code runs perfectly on a variety of our computers. I do have setuptools installed. I also tried to remove and reinstall it.
EDIT: For some reason, now it works. I don't think we can call it solved, because I did not do anything, but I also don't have the issue anymore.
The python you are using now is anaconda distribution. You have to install setuptools for that ditribution.
So use /home/.../anaconda/lib/python3.5/bin/pip and that will install it for this particular python.
I am new in python meep. I try to use python-meep on Ubuntu 10.04 64 bit (virtual machine).
I install all the necessary things like PCRE swig and python meep, but when I try to run the samples it gives me the same error as in the beginning:
~/Desktop/Python/python-meep/samples/bent_waveguide$ python python_meep_bent_wg.py
Traceback (most recent call last):
File "python_meep_bent_wg.py", line 21, in <module>
from meep import * # make it 'meep_mpi' for MPI-meep and 'meep' for non-MPI meep
File "/usr/local/lib/python2.6/dist-packages/meep.py", line 4693, in <module>
import scipy.weave
ImportError: No module named scipy.weave
(about scipy I have a problem to install it - I get the message:
Error: Dependency is not satisfiable: python (<< 2.6)
... so I install it with dpkg -i, and then made some updates but in the end I have some kind of broken packages)
Right now I am really stuck and have no idea what to do. Maybe somebody has an idea how to fix it or install it correctly overcoming all these problems.
Try to use the python-setuptools, so you install the stuff with pip or easy_install.