我希望能够定义应在我的所有conda环境中安装的标准软件包的列表。例如。当我创建一个新环境时,我知道我将始终需要jupyterlab,numpy,matplotlib,pandas等,如果我不必在创建的每个新环境中都安装它们,那就太好了。
总有可能吗?我在文档或互联网上的其他地方都找不到任何东西,但是也许我错过了一些东西……
现在,当我创建一个新环境时,必须手动指定在该环境中需要哪些软件包。因此,每次创建新环境时,我都必须
public IServiceProvider ConfigureServices(IServiceCollection services)
{
services.AddSingleton(Configuration);
SecretsMangerClientFactory secretsMangerClientFactory = new SecretsMangerClientFactory();
AWS.ConfigurationProvider configurationProvider = new AWS.ConfigurationProvider(secretsMangerClientFactory);
var awsCognitoClientOptions = configurationProvider.GetAsync<AWSCognitoClientOptions>(Constants.AppSettings.CognitoSettings).GetAwaiter().GetResult();
services.AddSingleton(awsCognitoClientOptions);
services.AddCognitoIdentity();
services.AddMvc()
.AddJsonOptions(options =>
{
options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
options.SerializerSettings.Converters = new[] { new EncryptionKeyConvertor() };
options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
})
.AddRazorPagesOptions(options =>
{
options.AllowAreas = true;
});
services.AddAntiforgery(o => o.HeaderName = "XSRF-TOKEN");
services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie();
services.ConfigureApplicationCookie(options =>
{
options.LoginPath = new PathString("/Applications/Identity/Login");
options.AccessDeniedPath = new PathString("/AccessDenied");
});
services.ApiVersioning();
services.AddMemoryCache();
ObjectFactory.Initialize(new ContainerFactory(), GetModules());
var container = (ObjectFactory.GetContainer() as DependencyContainer).InnerContainer;
container.Populate(services);
RegisterMonotone();
return container.GetInstance<IServiceProvider>();
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Error");
app.UseHsts();
}
app.UseEnableRequestRewind();
app.UseCors(builder => builder.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod());
app.UseMiddleware<CryptoCallContextInjectorMiddleware>();
app.UseMiddleware<ExceptionHandlerMiddleware>();
app.UseMiddleware<ProfilerInjectorMiddleware>();
app.UseMiddleware<APIKeyValidatorMiddleware>();
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseCookiePolicy();
app.UseAuthentication();
app.UseMvc();
}
这很繁琐,因为我需要很多软件包。
当前,我的主目录中有一个Shell脚本可以执行此工作,因此,如果我创建一个新环境,则只需要运行此脚本即可。但是,如果我能告诉conda在所有新环境中自动安装这些软件包,那就太好了。
答案 0 :(得分:1)
#export the current environment to yml file (txt file)
conda env export > environment.yml
# this will create new environment with all packages same as previous environment
conda env create -f environment.yml