unable to install pip on python 2.6.6 - lack of dependencies - pip

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

Related

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

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.

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.

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

"enchant C library not found" while installing pyenchant using pip on OSX

I typed in pip install pyenchant into my shell, but it raised two Traceback errors:
1:
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "/private/var/folders/q4/l70hdqjd5db2n2bdj69qrwz40000gq/T/pip_build_prernauppal/pyenchant/setup.py", line 195, in <module>
import enchant
File "enchant/__init__.py", line 90, in <module>
from enchant import _enchant as _e
File "enchant/_enchant.py", line 133, in <module>
raise ImportError("enchant C library not found")
ImportError: enchant C library not found
2:
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "/private/var/folders/q4/l70hdqjd5db2n2bdj69qrwz40000gq/T/pip_build_prernauppal/pyenchant/setup.py", line 195, in <module>
import enchant
File "enchant/__init__.py", line 90, in <module>
from enchant import _enchant as _e
File "enchant/_enchant.py", line 133, in <module>
raise ImportError("enchant C library not found")
ImportError: enchant C library not found
----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /private/var/folders/q4/l70hdqjd5db2n2bdj69qrwz40000gq/T/pip_build_prernauppal/pyenchant
I have python 2.7 default installed on my mac, but it still isn't working. I have already looked at Unable to install pyenchant-1.6.5 for python 2.7 on Mac OSX Lion but it doesn't answer my question, as easy_install pyenchant raises even more errors.
Try this - It worked for me on Ubuntu.
sudo apt-get install libenchant1c2a
You need to install enchant, which is a C library. You can use Homebrew, to do this kind of package management. Just enter:
brew install enchant
Before trying to pip install pyenchant and you should be fine.
Try either sudo pip install or sudo easy install.
[nltk_data] Error loading enchant: Package 'enchant' not found in
No. if you get this problem, you are supposed to install it like this:
$ sudo easy_install pyenchant
it is not an nltk package, it is a package on its own.
sudo easy_install
sudo because MAC permissions are usually messed up
Try a pip install, an easy_install, and a brew.
You have to download the NLTK package. That is how you get Pyenchant running. But if your building a grammar checker, pyenchant is not advisable because it only grammar checks two words. You should consider building a grammar checker on your own by starting with an autocomplete word completion from here:
How to code autocompletion in python?
For windows: download the required .exe file based on version from https://pypi.python.org/simple/pyenchant/
and pip install pyenchant

Ansible-galaxy throws ImportError: No module named yaml

When I try to install ansible role, I see this exception.
$ ansible-galaxy install zzet.postgresql
Traceback (most recent call last):
File "/Users/myHomeDir/.homebrew/Cellar/ansible/1.4.3/libexec/bin/ansible-galaxy", line 34, in <module>
import yaml
ImportError: No module named yaml
OS: Mac Os Maverick
Ansible: 1.4.3
Does anyone know how to fix it?
Based on the error message, it tries to import the python module yaml but cannot find it. The yaml module is called pyyaml when you install it with pip:
pip install pyyaml
If pip is not installed on your mac then you can install it as,
easy_install pip
For me pip install yaml doesn’t work in Mavericks.
pip install pyyaml works
I tried the pip install yaml answer, and it didn't work for me. I had to reinstall ansible in order for the command line to catch. IE,
failing
ansible-galaxy install bcen01.nodejs [43m] ✭
Traceback (most recent call last):
File "/usr/local/Cellar/ansible/1.4.3/libexec/bin/ansible-galaxy", line 34, in <module>
import yaml
ImportError: No module named yaml
reinstall
brew reinstall ansible
success
ansible-galaxy install bcen01.nodejs [43m] ✭
no version specified, installing master
- downloading role from https://github.com/bcen/ansible-nodejs/archive/master.tar.gz
- extracting bcen01.nodejs to /usr/local/etc/ansible/roles/bcen01.nodejs
bcen01.nodejs was installed successfully
Try installing with
sudo python -m easy_install pyyaml
The problem isn't in pyyaml, its in your version of setuptools. See http://codyaray.com/2011/12/pyyaml-using-easy_install-on-mac-os-x-lion for references
Run below commands to install latest yaml-
wget http://pyyaml.org/download/pyyaml/PyYAML-3.12.tar.gz
tar -xvzf PyYAML-3.12.tar.gz
cd PyYAML-3.12
python setup.py install
Python 2.7.12 (default, Sep 21 2017, 21:46:26)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import yaml
>>>

Resources