简体   繁体   中英

Using Sublime Text 2 with Portable Python

I have portable python and portable sublime text installed on a flash drive. I edited the python-build file so that it would use portable python to run the programs but it doesn't print anything into the sublime text window, it just opens up a command prompt window which immediately closes if the program stops or has an error. Is there anyway to make the output pop up in sublime text? Ideally, I would like to make this usable on all windows computers so I can keep my workflow portable!

Thanks!

I ran into the same problem and after a bit of troubleshooting, here is my solution:

1) Use the build system:

{
"cmd": ["\\Portable Python 2.7.6.1\\App\\python.exe", "-u", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python"}

This build will open your program in Python Portable. Instead of specifying your flash drive letter, using "\\" will go to the path relative to the root of the current drive.

2) At the end of your code add the following line to prevent force closing:

os.system("pause")

Also, don't forget to import the "os" module:

import os

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM