ModuleNotFoundError: No module named 'sympy' - python

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.

Related

downloaded SciPy for python, not able to use it

I am trying to download and use SciPy. According to pip I have already downloaded it however when I try to use it python says there is no module named SciPy. I have tried using python as well as python3. Here is a copy of my console:
➜ ~ pip3 install SciPy
Requirement already satisfied: SciPy in /usr/local/lib/python3.6/site-packages (0.19.1)
Requirement already satisfied: numpy>=1.8.2 in /usr/local/lib/python3.6/site-packages (from SciPy) (1.14.3)
➜ ~ pip install SciPy
Requirement already satisfied: SciPy in /usr/local/lib/python3.6/site-packages (0.19.1)
Requirement already satisfied: numpy>=1.8.2 in /usr/local/lib/python3.6/site-packages (from SciPy) (1.14.3)
➜ ~ python
Python 2.7.15 (default, Jun 2 2018, 12:02:49)
[GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import SciPy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named SciPy
>>> exit()
➜ ~ python3
Python 3.6.5 (default, Apr 28 2018, 01:16:46)
[GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import SciPy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'SciPy'
>>> exit()
➜ ~
Imports are case-sensitive. Use
import scipy

Failed to import tensorflow in python in Linux using pip3

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.

Difficulty Setting Up Numpy for Python 2.7 on Mac OSX

I'm trying to run a script of mine using Python 2.7. When I run
python2.7
I get
Python 2.7.10 (default, May 25 2015, 13:06:17)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.56)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
When I try to run my script, I get:
Traceback (most recent call last):
File "bcp.py", line 1, in <module>
import numpy as np
ImportError: No module named numpy
So Python 2.7 doesn't seem to know about numpy. When I run
pip2.7 install numpy
I get:
Requirement already satisfied (use --upgrade to upgrade): numpy in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
Cleaning up...
Any idea what's going on here?
Thanks!
This might be because you're using the wrong python distro on your computer. If you are using an OSX machine, there might be a python distribution in /usr/local/ and one in /System/Library/Frameworks. It seems like python2.7 might be linked to the one in /usr/.
Try
which python2.7
should locate which python distro "python2.7" is symlinked to. If you're symlinked to /usr/, just change it to the one in /System/Library and your numpy should work.

How to solve importing python packages " No module named "?

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.

ImportError: No module named mandrill

I installed mandrill using pip:
(venv)Jhons-MacBook-Pro:venv jhonjairoroa87$ pip install mandrill
I got this result:
Downloading/unpacking mandrill
Downloading mandrill-1.0.57.tar.gz
Running setup.py (path:/private/var/folders/x3/st96cn215h915kqwlcrmtspw0000gn/T/pip_build_jhonjairoroa87/mandrill/setup.py) egg_info for package mandrill
Requirement already satisfied (use --upgrade to upgrade): requests>=0.13.2 in /usr/local/lib/python2.7/site-packages (from mandrill)
Requirement already satisfied (use --upgrade to upgrade): docopt==0.4.0 in /usr/local/lib/python2.7/site-packages (from mandrill)
Installing collected packages: mandrill
Running setup.py install for mandrill
changing mode of build/scripts-2.7/mandrill from 644 to 755
changing mode of build/scripts-2.7/sendmail.mandrill from 644 to 755
changing mode of /usr/local/bin/mandrill to 755
changing mode of /usr/local/bin/sendmail.mandrill to 755
Successfully installed mandrill
Cleaning up...
But when I try to use it, fails:
(venv)Jhons-MacBook-Pro:venv jhonjairoroa87$ python
Python 2.7.6 (default, Sep 9 2014, 15:04:36)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import mandrill
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named mandrill
>>>
>>> import sendmail.mandrill
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named sendmail.mandrill
Has anyone had this problem?
I uninstalled it using
pip uninstall mandrill
and reinstalled it using the python -m option:
sudo python -m pip install mandrill
Now it works perfectly.
(venv)Jhons-MacBook-Pro:python_mandrill jhonjairoroa87$ python
Python 2.7.6 (default, Sep 9 2014, 15:04:36)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import mandrill
>>>

Categories

Resources