Anaconda3-5.1.0-MacOSX-x86_64.pkg 下载安装后,附带安装了pytorch包。
需要将环境调整到新的python3.6目录下。
https://www.jb51.net/article/148744.htm
1、在Project Interpreter选择“Show All…”菜单
1 Show All...
2、点击“+”,新增新的Interpreter
1 选择 : Add Local...
2. 选择 : System Interpreter
3、选择Anaconda3目录下的python3.6文件
1. 地址 : /anaconda3/bin/python3.6
4、确定之后,会有一个长时间的Task过程,应该是在Updating Python Interpreter过程。
5、测试代码:
from __future__ import print_function
import torch
# # import pymysql
# # pymysql.install_as_MySQLdb()
x = torch.rand(5, 3)
print(x)
6、输出结果
/Users/cody/anaconda3/bin/python #此处是指interpreter的位置
/Users/cody/PycharmProjects/codyPytorch/.../Pytorch_test.py #此处是指的文件位置
tensor([[0.4501, 0.1622, 0.2283],
[0.8682, 0.0824, 0.3198],
[0.8675, 0.2714, 0.2207],
[0.9131, 0.2409, 0.4074],
[0.9702, 0.5580, 0.7896]])
Process finished with exit code 0