如何在PyCharm中使用基本的Anaconda环境

时间:2019-01-25 03:44:20

标签: python pycharm

我在终端输入python程序时运行

activate base
python data_load.py

这是python所在的位置:

where python
C:\ProgramData\Anaconda3\python.exe

然后我尝试将PyCharm与Anaconda一起使用,然后转到“设置”>“项目解释器”>“添加本地”>“ Conda环境”>“现有环境”,并使用C:\ ProgramData \ Anaconda3 \ python.exe作为解释器。当我单击运行按钮时,data_load.py无法正常运行,并且出现运行时错误:

Traceback (most recent call last):
  File "C:/Users/Anonymous/PycharmProjects/pytorchHelloWorld/data_load.py", 
line 4, in <module>
import pandas as pd
  File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\__init__.py", 
line 42, in <module>
from pandas.core.api import *
  File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\api.py", 
line 10, in <module>
from pandas.core.groupby.groupby import Grouper
  File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\groupby\__init__.py", line 2, in <module>
from pandas.core.groupby.groupby import (
  File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\groupby\groupby.py", line 49, in <module>
from pandas.core.frame import DataFrame
  File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\frame.py", line 66, in <module>
from pandas.core.generic import NDFrame, _shared_docs
  File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\generic.py", line 43, in <module>
from pandas.core.internals import BlockManager
  File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\internals.py", line 76, in <module>
from pandas.core.sparse.array import _maybe_to_sparse, SparseArray
  File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\sparse\array.py", line 33, in <module>
import pandas._libs.sparse as splib
  File "pandas\_libs\sparse.pyx", line 17, in init pandas._libs.sparse
AttributeError: module 'numpy' has no attribute 'version'

1 个答案:

答案 0 :(得分:0)

您需要创建一个PyCharm环境。

步骤1: enter image description here

步骤2: enter image description here