[英]Set environment variable in bat file
I tried to use a library (mapnik )and the python binding with it. 我试图使用一个库(mapnik)和与其绑定的python。
The library is installed at D:\\install\\gis\\mapnik-v2.2.0
, then I add the following variable to the environment variable through the control panel: 该库安装在
D:\\install\\gis\\mapnik-v2.2.0
,然后通过控制面板将以下变量添加到环境变量中:
PATH: D:\install\gis\mapnik-v2.2.0\bin;D:\install\gis\mapnik-v2.2.0\lib
PYTHONPATH:D:\install\gis\mapnik-v2.2.0\python\2.7\site-packages
Then I run: 然后我运行:
python
>>import mapnik
This worked. 这工作了。
However, I do not want to set the variable to the global environment variable, so I tried to create a bat file like this: 但是,我不想将变量设置为全局环境变量,因此我尝试创建如下的bat文件:
setup_mapnik_path.bat: setup_mapnik_path.bat:
SET mapnik_path=D:\install\gis\mapnik-v2.2.0;
SET PATH=%PATH%;%mapnik_path%\lib;%mapnik_path%\bin;
SET PYTHONPATH=%PYTHONPATH%;%mapnik_path%\python\2.7\site-packages;
Then once I tried to run a script who use mapnik I will run the bat first: 然后,一旦我尝试运行使用mapnik的脚本,我将首先运行bat:
setup_mapnik_path.bat
python
>>import mapnik
But I will get error: 但是我会得到错误:
ImportError: No module named mapnik
Screenshot: http://pbrd.co/1lUk1F5 截图: http : //pbrd.co/1lUk1F5
What's the problem? 有什么问题?
What you listed as your script: 您列出为脚本的内容:
setup_mapnik_path.bat
python
>>import mapnik
just can NOT be a script, because ">>import mapnik" should be a keyboard input, right? 不能是脚本,因为“ >> import mapnik”应该是键盘输入,对不对?
You script should be like this: 您的脚本应如下所示:
call setup_mapnik_path.bat
python
Previous script call the first Batch file that define the variables, then return and execute python. 上一个脚本调用第一个定义变量的Batch文件,然后返回并执行python。 After that, you enter ">>import mapnik" via keyboard.
然后,通过键盘输入“ >> import mapnik”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.