我试图在我的 Kubuntu 机器上安装 jupyter 实验室。如果我使用 'pip3 install jupyter jupyterlab' 安装 jupyter lab,则命令 'jupyter notebook' 完全可以正常工作。但是,如果我每次收到消息时都尝试运行“jupyter lab”:
Traceback (most recent call last):
File "/usr/local/bin/jupyter", line 11, in <module>
sys.exit(main())
File "/usr/local/lib/python3.6/dist-packages/jupyter_core/command.py", line 230, in main
command = _jupyter_abspath(subcommand)
File "/usr/local/lib/python3.6/dist-packages/jupyter_core/command.py", line 133, in _jupyter_abspath
'Jupyter command `{}` not found.'.format(jupyter_subcommand)
Exception: Jupyter command `jupyter-lab` not found.
Run Code Online (Sandbox Code Playgroud)
怎么了?
我尝试以相同的问题多次重新安装 jupyter 和 jupyterlab。
我是node.js的新手,我已经决定将我的网站和API实现使用hapijs.
但是,我发现hapi社区已经构建并使用,lab
并且code
用于测试和断言库,这些库是一个重写mocha
和chai
.
我很难找到这些库之间的差异.
我知道有可能互换使用它们,但我想要更详细的比较,因为我想定义和遵守编码标准,我不喜欢混合和匹配库,除非有正当理由.
任何反馈都表示赞赏
每当Mongoose模型在加载后尝试加载时,都会抛出错误,例如:
错误:uncaughtException:
Account
编译后无法覆盖模型.date = Fri Feb 26 2016 10:13:40 GMT-0700(MST),pid = 19231,uid = 502,gid = 20,cwd =/Users/me/PhpstormProjects/project,execPath =/usr/local/Cellar/node/0.12.4/bin/node,version = v5.2.0,argv = [/ usr/local/Cellar/node/0.12.4/bin/node,/ usr/local/Cellar/node0.12.4/bin/lab],rss = 73306112,heapTotal = 62168096,heapUsed = 29534752,loadavg = [1.6005859375,1.84716796875,1.8701171875],uptime = 648559 OverwriteModelError:Account
编译后无法覆盖模型.
我很好,但现在我正在为我的模型编写单元测试,我遇到了一个问题.
我将所有Mongoose模型放在文件src/models/
夹内的单独文件中,并且要加载这些模型,只需要文件夹,将Mongoose
对象传递给它,src/models/index.js
文件将加载所有模型,并返回一个对象楷模.这个index.js
文件可以在这里看到(而不是它的相关,但模型名称基本上是文件名,没有.js)
现在,模型的单元测试也分成单独的文件.每个模型都有一个测试文件.即使每个单元测试文件都关注特定模型,其中一些也使用其他模型(用于之前/之后的任务).
我刚刚创建了第二个单元测试文件,当我独立执行每个单元时,它们工作得很好.但是当我执行所有这些操作时,我收到上述错误,说明我试图多次加载模型.因为我需要./models
在每个单元测试用例中,所以我不止一次加载它们.
我想也许我可以after()
在每个单独的单元测试文件中清除所有加载的模型,如下所示:
after(function(done) {
mongoose.connection.close(function() {
mongoose.connection.models = {}
done()
})
})
Run Code Online (Sandbox Code Playgroud)
哪个根本不起作用(没有新的错误,但是一旦编译错误仍然存在,同样不能覆盖Account
模型 …
有谁知道的意思?
错误的ERR!测试失败.请参阅上文了解更多详情.
3 tests complete
Test duration: 873 ms
The following leaks were detected:lr
npm ERR! Test failed. See above for more details.
Run Code Online (Sandbox Code Playgroud)
我运行我的3个测试我得到了一个成功的绿色3测试完成(我所有的测试都通过),但为什么我也看到讨厌的?
错误的ERR!测试失败.请参阅上文了解更多详情.
我想在测试时覆盖一些值,特别是将HTTP服务的重试次数设置为1(立即失败,不重试)。我们的项目使用node-config
。根据文档,我可以用NODE_CONFIG
env变量覆盖:
node myapp.js --NODE_CONFIG='{"Customer":{"dbConfig":{"host":"customerdb.prod"}}}'
Run Code Online (Sandbox Code Playgroud)
好吧,我宁愿在我的测试中这样做,但不是对所有测试都这样做。该代码说,您可以通过设置允许配置突变ALLOW_CONFIG_MUTATIONS
。
process.env.ALLOW_CONFIG_MUTATIONS = "true";
const importFresh = require('import-fresh');
importFresh("config");
process.env.NODE_CONFIG = JSON.stringify({httpServices:{integration:{enrich: {retryInterval: 1, retries: 1}}}});
expect(process.env.NODE_CONFIG, 'NODE_CONFIG not set').to.exist();
expect(process.env.NODE_CONFIG, 'NODE_CONFIG not set').to.match(/retryInterval/);
expect(process.env.ALLOW_CONFIG_MUTATIONS, 'ALLOW_CONFIG_MUTATIONS not set').to.equal("true");
const testConfig = require("config");
console.dir(testConfig.get("httpServices.integration.enrich"));
expect(testConfig.get("httpServices.integration.enrich.retryInterval"), 'config value not set to 1').to.equal(1);
Run Code Online (Sandbox Code Playgroud)
结果:
{ url: 'https://internal-**********',
retryInterval: 5000,
retries: 5 }
`Error: config value not set to 1: Expected 5000 to equal specified value: 1`
Run Code Online (Sandbox Code Playgroud)
我如何获得此替代才能正常工作?
(预期来自Hapi.js代码库)
我导入了Slider:
import Slider from '@material-ui/lab/Slider';
Run Code Online (Sandbox Code Playgroud)
并已在渲染中返回。
代码未编译,并引发错误:
找不到模块:错误:
Can't resolve '@material-ui/lab/Slider' in {path}
。
有人可以帮我吗?谢谢。
我正在为一个函数编写测试代码,该函数将检查twitter中是否存在用户名.我正在使用Hapi框架和实验室进行测试.
当我运行时,npm test
我收到以下错误:
> NameGen@0.0.0 test /Users/mario/projects/NameGen
> ./node_modules/lab/bin/lab -c
/Users/mario/projects/NameGen/test/test.js:5
Lab.experiment( "Test Username Existence", function() {
^
TypeError: Object #<Object> has no method 'experiment'
at Object.<anonymous> (/Users/mario/projects/NameGen/test/test.js:5:5)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js [as origLoader] (module.js:474:10)
at Object.require.extensions..js (/Users/mario/projects/NameGen/node_modules/lab/lib/coverage.js:32:26)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at /Users/mario/projects/NameGen/node_modules/lab/lib/cli.js:85:23
at Array.forEach (native)
at Object.internals.traverse (/Users/mario/projects/NameGen/node_modules/lab/lib/cli.js:81:19)
at Object.exports.run (/Users/mario/projects/NameGen/node_modules/lab/lib/cli.js:30:29)
at Object.<anonymous> (/Users/mario/projects/NameGen/node_modules/lab/bin/lab:3:23)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at …
Run Code Online (Sandbox Code Playgroud) lab ×7
node.js ×4
hapijs ×3
jupyter ×1
jupyter-lab ×1
material-ui ×1
mocha.js ×1
mocking ×1
mongoose ×1
node-config ×1
python ×1
reactjs ×1
testing ×1
unit-testing ×1