简体   繁体   English

如何使用python将目录路径添加到环境变量

[英]How do I add the path to a directory to the environment variables using python

I want to know if it is possible to add the path to a directory to the environment variables permanently using python. 我想知道是否可以使用python将目录的路径永久添加到环境变量中。 I have seen other questions that relate to mine but the answers there only add the path temporarily,I want to know if there's a way to add it permanently 我看过其他与我有关的问题,但那里的答案只是暂时添加路径,我想知道是否有永久添加路径的方法

While using bash add this ~/.bashrc export PYTHONPATH="${PYTHONPATH}:/Home/dev/path 在使用bash的同时,添加~/.bashrc export PYTHONPATH="${PYTHONPATH}:/Home/dev/path

Make sure the directory you point to has at the topmost init.py file in your directory structure 确保指向的目录在目录结构中位于最顶层的init.py文件中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在环境变量的用户变量中添加 PATH 变量? - How do i add a PATH variable in the user variables of the environment variables? 如何使用 dockerfile 在 python 脚本中设置环境变量? - How do I set environment variables in a python script using a dockerfile? 使用环境变量将包路径添加到python .pth文件 - Add package path to python .pth file using environment variables 如何将wires.exe目录添加到系统环境变量 - How do I add the wires.exe directory to the system environment variables 如何使用 Python 将任何目录添加到 PATH? - How Can I add any directory to PATH using Python? 如何在 Python 中访问环境变量? - How do I access environment variables in Python? 如何从 Lambda 动态推送/添加条目以响应 Python 中的环境变量? - How do I Push/add entries from Lambda response to environment variables in Python dynamically? 如何使用 python::virtualenv 在 puppet 中创建 python 环境变量? - How do I create python environment variables in puppet using python::virtualenv? 如何使用 Python 将项目添加到 PATH 用户环境变量 - How to add items to the PATH User Environment Variable Using Python 如何在 python 中使用同一 shell 中的脚本导出环境变量? - How do I export environment variables using a script in the same shell in python?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM