E: Package 'python-scipy' has no installation candidate - installation

Upon installing a software, I am finding the following error multiple times.
$ sudo python setup.py install
Traceback (most recent call last):
File "setup.py", line 24, in <module>
from software_name import PACKAGE_NAME
File "/home/username/Softwares/software_name/__init__.py", line 29, in <module>
import scipy
ImportError: No module named scipy
I can install many of the missing modules with, e.g., sudo apt-get install -y python-numpy, but sometimes I get:
username#username:~/Softwares/software_name$ sudo apt-get install -y python-scipy
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package python-scipy is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'python-scipy' has no installation candidate
And I am really not sure what is going on?

The package you want is python3-scipy, not python-scipy. It can be installed using:
apt install python3-scipy
You might be better off installing scipy via pip (for Python 2) or pip3 (for Python 3). pip is a package manager for Python packages.
pip install scipy
or
pip3 install scipy
If you run into a similar problem in the future, you can use pip3 search scipy with the relevant search term to look for the required package. Check out man pip3 for the details.

Related

'scipy' seems to be installed but can not be imported

Here is the error I am receiving when running python 3.10.1 in my terminal.
import scipy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'scipy'
I used
pip3 install scipy
and everything seemed to work. If I run it again I receive this
pip3 install scipy
Requirement already satisfied: scipy in /usr/local/lib/python3.9/site-packages (1.8.0)
Requirement already satisfied: numpy<1.25.0,>=1.17.3 in /usr/local/lib/python3.9/site-packages (from scipy) (1.22.3)
I also tried
brew install scipy
and that too seemed to work and if I run it again I get this message
brew install scipy
Warning: scipy 1.8.0 is already installed and up-to-date.
To reinstall 1.8.0, run:
brew reinstall scipy
Why wont python3 import scipy?
I ran this in terminal and now everything works
python3 -m pip install scipy
I am still unsure what the original issue was however it may be related to this post here.

ModuleNotFoundError: No module named 'talib'

Cannot install ta-lib on MacOS.
pip install ta-lib
How to install it?
Try:
brew install ta-lib
pip install ta-lib
Source: https://github.com/enigmampc/catalyst/issues/187#issuecomment-374552524
Faced the issue on Big sur again
The situation:
brew install ta-lib was successful and so was pip install TA-Lib
version 0.4.19
On console:
>>> import talib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'talib'`
Solution: Installing from source worked for me, here are the steps
Install ta-lib using homebrew brew install ta-lib, this is required
Download the source from TALIB_SOURCE
untar/unzip the download ( tar -xvzf mrjbq7-ta-lib-TA_Lib-0.4.19-19-g5eb3fa4.tar.gz
cd into the folder and run:
pip install -r requirements.txt
python setup.py install
import talib should be working now
Here is the solution that usually works for me. In the file you are trying to import the module copy and paste the following code and run it. Then you will be ready to go.
from pip._internal import main as install
install(["install","ta-lib"])
Hope this will work for you, Good luck.

unable to install pip on python 2.6.6 - lack of dependencies

I'm on Ubuntu 18.04 and using python 2.6.6 that I installed from tgz package from here https://www.python.org/downloads/release/python-266/ using this instruction: https://askubuntu.com/questions/25961/how-do-i-install-a-tar-gz-or-tar-bz2-file. I'm trying to install pip using this instruction https://pip.pypa.io/en/latest/installing/
but when I run
python get-pip.py
I got errors about dependencies:
Traceback (most recent call last): File "get-pip.py", line 28, in
import tempfile File "/usr/local/lib/python2.6/tempfile.py", line 34, in
from random import Random as _Random File "/usr/local/lib/python2.6/random.py", line 47, in
from os import urandom as _urandom ImportError: cannot import name urandom
First it was cannot import name zlib. I installed zlib and now I got about urandom so I guess there might be more that I don't have installed. What's the best way to deal with it?
You could try sudo. If that doesn't work, try stating the python version.
$ sudo python2.6 get-pip.py
I think it is better to install via OS package:
apt install python python-pip python-setuptools

basic mlxtend example giving invalid syntax error

I'm using Python 3.5.2 on Ubuntu 16.04.
I've installed sklearn using..
sudo apt install python-sklearn
and mlxtend using...
sudo pip3 install mlxtend
I'm trying to run the basic Iris example found on the Internet, but I am getting an error as soon as I try to import plot_decision_regions from mlxtend.plotting:
from mlxtend.plotting import plot_decision_regions
Traceback (most recent call last):
File "scripts/machine.learning.py", line 6, in <module>
from mlxtend.plotting import plot_decision_regions
File "/usr/local/lib/python3.5/dist-packages/mlxtend/plotting/__init__.py", line 15, in <module>
from .heatmap import heatmap
File "/usr/local/lib/python3.5/dist-packages/mlxtend/plotting/heatmap.py", line 74
raise AssertionError(f'len(row_names) (got {len(row_names)})'
^
SyntaxError: invalid syntax
I had the same error, just upgrade to python3.7 the real error is
python 3.5 does not support f prefix
upgrade using conda
conda install -c anaconda python=3.7
and then update all depencies
conda update --all
I'm not seeing the same error as you, but try remove legend=range(105, 150) from plot_decision_regions i.e.
plot_decision_regions(x_combined, y_combined, clf=tree)
I'm using the latest current sklearn, i.e.
import sklearn
sklearn.__version__
'0.21.3'
Perhaps remove that version
sudo apt-get remove python-sklearn
Then install via pip, i.e.
pip3 install scikit-learn

Pytorch installation issue under Anaconda

I followed the link here to install fastai library using pip install git+https://github.com/fastai/fastai.git
It gave me the following error message. These messages keep the same even I installed Pytorch successfully using conda install pytorch-cpu -c pytorch
and pip3 install torchvision. What can be the reason?
Collecting torch<0.4 (from fastai==0.7.0)
Using cached https://files.pythonhosted.org/packages/5f/e9/bac4204fe9cb1a002ec6140b47f51affda1655379fe302a1caef421f9846/torch-0.1.2.post1.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\shuxi\AppData\Local\Temp\pip-install-7sjptuad\torch\setup.py", line 11, in <module>
raise RuntimeError(README)
RuntimeError: PyTorch does not currently provide packages for PyPI (see status at https://github.com/pytorch/pytorch/issues/566).
Please follow the instructions at http://pytorch.org/ to install with miniconda instead.
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\shuxi\AppData\Local\Temp\pip-install-7sjptuad\torch\
To fix this, do:
$ pip install --upgrade git+https://github.com/fastai/fastai.git
OR
$ pip install --no-cache-dir git+https://github.com/fastai/fastai.git
Your command probably failed because you have installed a old version of torch (0.1.2) some time ago. pip was not supported for torch install for that version and pip instead redirected the user to open pytorch.org in the browser. In your case, pip is reusing this cached package. --upgrade forces pip to choose latest version of all depending packages.

Resources