I used pip3 to install tensorflow.. And after installation, I can find it in
/usr/local/lib/python3.6/site-packages
Besides, I use pip3 list and find it on the list:
vincent#ubuntu:/usr/local/lib/python3.6/site-packages/tensorflow$ pip3 list
backports.weakref (1.0rc1)
bleach (1.5.0)
html5lib (0.9999999)
Markdown (2.6.8)
numpy (1.13.1)
pip (9.0.1)
protobuf (3.3.0)
setuptools (28.8.0)
six (1.10.0)
tensorflow (1.2.1)
Werkzeug (0.12.2)
wheel (0.29.0)
But but I failed to import it in python3.6
vincent#ubuntu:/usr/local/lib/python3.6/site-packages/tensorflow$ python
Python 3.6.1 |Anaconda 4.4.0 (64-bit)| (default, May 11 2017, 13:09:58)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'tensorflow'
>>>
What's wrong with it?
I ran it in Linux14.04(x64) in VMware
There may be multiple versions of python installed. You can do the following to ensure that tensorflow is installed for the version you are using -
python -mpip install tensorflow
Here I assume that you are using python prompt to run python. If you are using a different prompt just use that in place of python.
Related
I have tried to install matplotlib in my environment "cs323V2"with the following commands:
(cs323V2) conda install matplotlib
Collecting package metadata (current_repodata.json): done
Solving environment: done
# All requested packages already installed.
Retrieving notices: ...working... done
(cs323V2) python
Python 2.7.5 (default, Nov 16 2020, 22:23:17)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
[3]+ Stopped python
>>> import matplotlib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'matplotlib'
Use the conda-forge channel.
conda install -c conda-forge matplotlib
I am not really sure why only
conda install matplotlib
does not work.
Solved: Learn about virtual environments.
pip install virtualenv
Problem: I get a ModuleNotFoundError for psycopg2 in python3, though it's successfully installed via pip3. (I posted short code to summarize from the terminal, but the errors are of course bugging me with .py scripts I'm trying to run.)
Python3 packages:
macs-MacBook-Air-2% pip3 list
Package Version
---------- -------
pip 19.2.3
psycopg2 2.8.4
setuptools 41.4.0
wheel 0.33.6
Python3 psycopg2 error:
macs-MacBook-Air-2% python3
Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 16:52:21)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import psycopg2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'psycopg2'
I've only done:
pip3 install psycopg2
Extra notes:
As a side note, everything works fine when I run 2.7. (I used pip install psycopg2.)
macs-MacBook-Air-2% python
Python 2.7.10 (default, Oct 6 2017, 22:29:07)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import psycopg2
>>> psycopg2.__version__
'2.8.4 (dt dec pq3 ext lo64)'
>>>
python 2.7 packages:
macs-MacBook-Air-2% pip list
DEPRECATION: ...2.7 end of life notice..
Package Version
-------------------------------------- -----------
altgraph 0.10.2
astroid 1.6.6
...more
psycopg2 2.8.4
...more
zope.interface 4.6.0
I'm very new to coding, and I searched this error. But, I did not find results that made sense to me including both a python3 error + successful python3 installation.
This could be because your default python installation is Python 2. I think you should create a virtual environment and the install psycopg2 on it. This way you will use pip3 and have isolated dependencies that won't generate conflicts with other versions (and maybe corrupt your system):
python3 -m venv ~/.environments/test
source ~/.environments/test/bin/activate
pip install psycopg2
I'm on MacOSX Mojave 10.14.6 on a MacBook Pro 2015. So I pip installed sympy, right?
I head over to my shell, run python3, and do:
$python3
Python 3.7.4 (v3.7.4:e09359112e, Jul 8 2019, 14:36:03)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sympy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'sympy'
Just to be sure, I pip installed again just to make sure.
$ pip install sympy
Requirement already satisfied: sympy in /usr/local/lib/python3.7/site-packages (1.4)
Requirement already satisfied: mpmath>=0.19 in /usr/local/lib/python3.7/site-packages (from sympy) (1.1.0)
My pip list also includes sympy as sympy 1.4.
What's wrong here? Is there another setup step I've missed?
Apparently all I had to do was
python3 -m pip install sympy
Mac being weird with two built in pythons and a third python for user.
Pro tip: use a virualenv.
I am trying to run a python script which needs numpy module ,when I try to install it,it shows it is already present, when I run import numpyit throws the error ImportError: No module named numpy,any guidance on what is wrong?
[username#machine build]$ pip install numpy
You are using pip version 7.1.0, however version 18.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Requirement already satisfied (use --upgrade to upgrade): numpy in /usr/lib64/python2.6/site-packages
Below command shows numpy is not installed
[username#machine build]$ python
Python 2.7.12 (default, Feb 22 2017, 20:16:44)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print(sys.version)
2.7.12 (default, Feb 22 2017, 20:16:44)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-11)]
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named numpy
If you're running Linux then use python2.7 -m pip install numpy
For python version 2.7 use python2.7 -m pip install numpy
Alternatively, on Windows under bash use py -2.7 -m pip install numpy
I am coming across a strange problem, I already installed python packages but it doesn't recognize them. please note that some packages are recognizable.
An example of importing a package
ActivePython 2.7.5.6 (ActiveState Software Inc.) based on
Python 2.7.5 (default, Sep 16 2013, 23:07:15)
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named requests
Whenever I try to install it using Pip like
sudo pip install requests
I got this message whenever I try to install the same package.
Requirement already satisfied (use --upgrade to upgrade): requests in /usr/local/lib/python2.7/site-packages
What should I do to solve this problem ?
UPDATE_1
pip --version
pip 7.1.2 from /usr/local/lib/python2.7/site-packages
Find where pip installs your package and add the path to
export PYTHONPATH=<path>
#my path was /Library/Python/2.7/site-packages
in your .bashrc or .profile file.