how does anaconda use packages installed by pip3? - pip

I have been using pip3 to install packages for python3. But I heard anaconda is a better choice, so I installed anaconda, and my python3 is automatically connected to anaconda. Now every time I enter python3, some of my packages such as tensorflow, keras couldn't be imported.
>>> import tensorflow
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'tensorflow'
I can find tensorflow and keras in pip3 list, but not in conda list. I have done some google search, but my problem stays. Any help would be appreciated.

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.

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.

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

ImportError: Entry point ('console_scripts', 'pip') not found on Mac

I got the message
You are using pip version 8.0.2, however version 8.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
When I try to install a package through pip.
I followed the instruction and upgrade pip with pip install --upgrade pip. Now I'm getting an error with pip, even with pip --version to check the version of pip.
Traceback (most recent call last):
File "/usr/local/bin/pip", line 9, in <module>
load_entry_point('pip==8.0.2', 'console_scripts', 'pip')()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 357, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2393, in load_entry_point
raise ImportError("Entry point %r not found" % ((group,name),))
ImportError: Entry point ('console_scripts', 'pip') not found
I've searched online and found some similar issues like, this, this and this. but none of the solutions worked for me.
I think it might be I have multiple version of pip on my Mac, how can I clean it up and get the latest version installed, please?
Thank you.
Manually removed all pip repositories in /usr/local/bin/. (not sure if it's necessary.)
Then reinstall pip following the instructions here.
To install pip, securely download get-pip.py.
Then run the following:
python get-pip.py
FYI, easy-install pip doesn't work.

How can I use jython setup.py install?

I am using a Jython virtualenv where I can install whatever software via pip or via easy_install, but there is a software that is not registered yet and the installation mode via:
[sudo] python setup.py install
and I am trying to do the same with jython:
[sudo] jython setup.py install
So, I am getting these follow errors:
Traceback (most recent call last):
File "setup.py", line 3, in <module>
from setuptools import setup, find_packages
ImportError: No module named setuptools
I checked and installed jython ez_setup.py again.
I downloaded the yolk and didn't solved too.
My folder:
╭─hudson#hudson-pc ~/jython2.7a1/Lib/site-packages ‹› ‹master*›
╰─$ ls
easy-install.pth setuptools.pth yolk 0.4.3-py2.7.egg README should_dsl-2.0a5-py2.7.egg setuptools-0.6c11-py2.7.egg virtualenv-1.7.2-py2.7.egg
And at the normal(real) environment, without virtualenvs, I got the same erros.
At Python I already installed this software and worked well.
If I enter at Jython Shell and try import setuptools, I got the same erros too:
>>> import setuptools
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named setuptools
>>> import sys
>>> sys.path
['', '/home/hudson/jython2.7a1/Lib', '/home/hudson/__classpath__', '/home/hudson/__pyclasspath__']
Then, I add the site-packages to the sys (It can be a stupid attempt):
>>> sys.path.append('/home/hudson/jython2.7a1/Lib/site-packages')
>>> sys.path
['', '/home/hudson/jython2.7a1/Lib', '/home/hudson/__classpath__', '/home/hudson/__pyclasspath__', '/home/hudson/jython2.7a1/Lib/site-packages']
>>> import setuptools
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named setuptools
Why is not recognizing?
If pip "works" then you could use it to install your software. To try it, run from a directory with setup.py:
$ pip install -e .
If you have a tarball of the package:
$ pip install your_package-0.0.1.tar.gz
pip can install from a git repository, use custom urls from where to get packages, etc.
I've tested it: jython works with virtualenv, distribute (a fork of setuptools), pip. So jython can install a package if it uses setuptools in setup.py.
Basically you need to install the installtool first. To do so see the doc linked below.
install this: http://peak.telecommunity.com/dist/ez_setup.py
(see here:http://www.jython.org/jythonbook/en/1.0/appendixA.html#setuptools)

Resources