python - 执行 Python 模块而不安装它
问题描述
我们如何在没有安装 pandas 的环境中运行实现 pandas 模块的 python 脚本?
例如,在服务器上,我们无权安装 python 模块。我们有一个使用 pandas 模块的脚本,那么我们如何运行这些脚本呢?
解决方案
In short: no, you can't. You have to install the package.
There are at least two options. First, you can install the packages that are not in the system to your home dir (but this is messy and dependent on the changes to the OS-level setup). You use:
pip install --user pandas
However, a better way is to use virtual environment (e.g. venv
):
python -m venv local-env
In this way you can create a local copy of Python environment in which you can install pandas
and any other dependencies of your code. And it is fully under your control.
On venv
you can read more in the Python documentation.
推荐阅读
- python - 如何打印一个字符串,显示字符串中每个字符重复的次数?
- javascript - 自定义 CTA 按钮插件 CK5Editor
- python - 如何持续交付部署在 Azure 中的 Python 函数应用程序?
- python - 在 Pandas Dataframe 中创建具有组中行位置的新列
- c# - AutoMapperMappingException:缺少类型映射配置或不支持的映射
- c - Activate some bits of a number in C
- r - 为什么 col_search 有时有效,有时无效,无论是否有效
- c# - 将正确信息添加到新工作表
- ios - Core Data + CloudKit 不会在其他设备上自动刷新?
- c# - 获取由空格分隔的字符串的最后一个元素