问题描述
我遇到了 Atom 文本编辑器的问题。我正在尝试访问 imaplib 包中的 class AsyncArray extends Array {
#INDEX;
constructor(...ps){
super(...ps);
if (this.some(p => p.constructor !== Promise)) {
throw "All AsyncArray items must be a Promise";
}
}
[Symbol.asyncIterator]() {
this.#INDEX = 0;
return this;
};
next() {
return this.#INDEX < this.length ? this[this.#INDEX++].then(v => ({value: v,done: false}))
: Promise.resolve({done: true});
};
};
var aa = AsyncArray.from({length:10},(_,i) => new Promise(resolve => setTimeout(resolve,i*1000,[i,~~(Math.random()*100)])));
async function getAsycRandoms(){
for await (let random of aa){
console.log(`The Promise at index # ${random[0]} gets resolved with a random value of ${random[1]}`);
};
};
getAsycRandoms();
属性:
IMAP4_SSL
引发以下错误:
import imaplib
...
conn = imaplib.IMAP4_SSL("some.mail.server")
我一直在寻找原因。从 conda 提示符尝试上面的代码后,错误消失了。所以,我认为它应该与 Atom 的编辑器或“脚本”包有关。我检查了 Atom 的 AttributeError: module 'imaplib' has no attribute 'IMAP4_SSL'
和 sys.path
,没有任何问题。 sys.version
配置如下:
python.coffee
编辑:我认为包导入成功,因为我可以访问它的其他属性,如 exports.Python =
'Selection Based':
command: 'python'
args: (context) ->
code = context.getCode()
tmpFile = GrammarUtils.createTempFileWithCode(code)
return ['-u',tmpFile]
Edit2:很可能我的问题与我在 Windows Powershell 中启动 python 时得到的以下提示有关:
IMAP
我已经尝试运行 This Python interpreter is in a conda environment,but the environment has
not been activated. Libraries may fail to load. To activate this environment
please see https://conda.io/activation
脚本但没有成功,请注意 Anaconda 安装在另一个装有 Windows 的驱动器中。但是以下路径已经包含在环境变量中:
activate.bat
解决方法
原来我的答案就在这里,我的 conda 环境没有问题