我需要 conda 环境来运行一些 python 存储库。早些时候,我在我的 Windows PC 中有代码,我安装了 Anaconda shell,其他一切都很好......简单!!
但是,现在我已将代码移至服务器(由于内存要求)。我使用 Putty 客户端访问该服务器,并且所有操作都必须使用 Putty shell 执行。我如何从那里运行 conda?我使用pip install conda 安装了 conda ,但每次尝试运行 conda 命令时,都会抛出以下错误
ERROR: The install method you used for conda--probably either `pip install conda`
or `easy_install conda`--is not compatible with using conda as an application.
If your intention is to install conda as a standalone application, currently
supported install methods include the Anaconda installer and the miniconda
installer. You can download the miniconda installer from
https://conda.io/miniconda.html.
Run Code Online (Sandbox Code Playgroud)
经过搜索,我发现使用 …
我正在使用 dotnet core 开发 webApi,该核心从 IFormFile 获取 excel 文件并读取其内容。我正在关注文章 https://levelup.gitconnected.com/reading-an-excel-file-using-an-asp-net- core-mvc-application-2693545577db正在做同样的事情,只不过这里的文件存在于服务器上,而我的文件将由用户提供。
这是代码:
public IActionResult Test(IFormFile file)
{
List<UserModel> users = new List<UserModel>();
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
using (var stream = System.IO.File.Open(file.FileName, FileMode.Open, FileAccess.Read))
{
using (var reader = ExcelReaderFactory.CreateReader(stream))
{
while (reader.Read()) //Each row of the file
{
users.Add(new UserModel
{
Name = reader.GetValue(0).ToString(),
Email = reader.GetValue(1).ToString(),
Phone = reader.GetValue(2).ToString()
});
}
}
}
return Ok(users);
}
}
Run Code Online (Sandbox Code Playgroud)
当 system.IO 尝试打开文件时,它无法找到路径,因为路径不存在。如何获取文件路径(根据用户选择的文件而有所不同)?还有其他方法可以实现吗?
PS:我不想先将文件上传到服务器上,然后再读取。