我在Windows 10上运行Anaconda3,并使用安装了自定义软件包
C:\Users\username\Anaconda3\envs\myenv\Scripts\pip install mypackage
因此,此命令将软件包安装在内部
C:\Users\username\Anaconda3\envs\myenv\Lib\site-packages\mypackage
如果我启动 Anaconda提示并运行
conda activate myenv
python
>> import mypackage
我什么都没问题,但是在Spyder中,我遇到了 ModuleNotFoundError
Anaconda提示
conda activate myenv
python
>> import sys; sys.executable
'C:\\Users\\username\\Anaconda3\\envs\\myenv\\python.exe'
>> import os; os.environ['PATH']
'C:\\Users\\username\\Anaconda3\\envs\\myenv;C:\\Users\\username\\Anaconda3\\envs\\myenv\\Library\\mingw-w64\\bin;C:\\Users\\username\\Anaconda3\\envs\\myenv\\Library\\usr\\bin;C:\\Users\\username\\Anaconda3\\envs\\myenv\\Library\\bin;C:\\Users\\username\\Anaconda3\\envs\\myenv\\Scripts;C:\\Users\\username\\Anaconda3\\envs\\myenv\\bin;C:\\Users\\username\\Anaconda3\\condabin;C:\\Program Files (x86)\\Intel\\iCLS Client;C:\\Program Files\\Intel\\iCLS Client;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0;C:\\Windows\\System32\\OpenSSH;C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\DAL;C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\DAL;C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\IPT;C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\IPT;C:\\Program Files\\nodejs;C:\\Program Files\\Git\\cmd;C:\\Users\\username\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\username\\AppData\\Roaming\\npm;C:\\Users\\username\\Anaconda3\\envs\\myenv\\lib\\site-packages\\pywin32_system32'
Spyder
In[8]: import sys; sys.executable
Out[8]: 'C:\\Users\\username\\Anaconda3\\envs\\myenv\\pythonw.exe'
In[13]: import os; os.environ['PATH']
Out[13]:'C:\\Users\\username\\Anaconda3\\envs\\myenv;C:\\Users\\username\\Anaconda3\\envs\\myenv\\Library\\mingw-w64\\bin;C:\\Users\\username\\Anaconda3\\envs\\myenv\\Library\\usr\\bin;C:\\Users\\username\\Anaconda3\\envs\\myenv\\Library\\bin;C:\\Users\\username\\Anaconda3\\envs\\myenv\\Scripts;C:\\Users\\username\\Anaconda3\\envs\\myenv\\bin;C:\\Users\\username\\Anaconda3\\condabin;C:\\Users\\username\\Anaconda3;C:\\Users\\username\\Anaconda3\\Library\\mingw-w64\\bin;C:\\Users\\username\\Anaconda3\\Library\\usr\\bin;C:\\Users\\username\\Anaconda3\\Library\\bin;C:\\Users\\username\\Anaconda3\\Scripts;C:\\Program Files (x86)\\Intel\\iCLS Client;C:\\Program Files\\Intel\\iCLS Client;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0;C:\\Windows\\System32\\OpenSSH;C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\DAL;C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\DAL;C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\IPT;C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\IPT;C:\\Program Files\\nodejs;C:\\Program Files\\Git\\cmd;C:\\Users\\username\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\username\\AppData\\Roaming\\npm;C:\\Users\\username\\Anaconda3\\envs\\myenv\\lib\\site-packages\\pywin32_system32;C:\\Users\\username\\Anaconda3\\envs\\myenv\\lib\\site-packages\\pywin32_system32'