installed pytorch1.0.1 for OS X with pip3 but cannot import, what can I do?
I have already installed pytorch for MacOS 10.14 with pip3, but I can not import it in the python script. What should I do?

System: MacOS 10.14

Python3: v3.7

➜  ~ pip3 list
Package     Version    
----------- -----------
numpy       1.16.2     
Pillow      5.4.1      
pip         18.1       
pycairo     1.17.1     
pygobject   3.28.3     
setuptools  40.5.0     
six         1.12.0     
torch       1.0.1.post2
torchvision 0.2.2.post3
virtualenv  16.1.0     
wheel       0.32.2     
➜  ~ python3 
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 26 2018, 23:26:24) 
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
&gt;&gt;&gt; import torch
Traceback (most recent call last):
File "&lt;stdin&gt;", line 1, in &lt;module&gt;
ModuleNotFoundError: No module named 'torch'
&gt;&gt;&gt; 


To expand upon my comment:

There's no strict guarantee that a pip3 wrapper script somewhere on your system is related to the pip package manager/module for your python3 binary. That wrapper may be created by a different installation of Python – maybe your system's own, maybe something else. (You can see where the script is located with which pip3 and see which interpreter it uses with less $(which pip3) and looking at the shebang line at the top.)

Each version of Python you have installed has its own site-packages directory, which contains the globally (as far as that version is concerned) installed packages. Fortunately, pip can be run exactly equally as the wrapper script would with the -m switch, so to be sure Torch and Torchvision get installed into your python3 (which appears to be Python 3.7.0 at this time),

python3 -m pip install torch torchvision


should do the trick.

However, globally (well, interpreter-globally, as discussed above) installed packages should be avoided, since you can easily get into hairy conflicts when you're working on multiple projects. You should instead use virtualenvs to separate your library installations from each other – the venv module is included in Python these days, and the official documentation has a guide on it. (Other options are pipenv and poetry, but it's worth knowing the lower-level tooling.)
