I am trying to using sublime text 3 for python development with virtualenv! I've read the answer that i can find on Stackoverflow and baidu(our national search engine ),but i am still very confused. i hope you can help me,tank you very much! My computer system:ubuntu 17.04 My sublime configuration file:
{
"folders":
[
{
"follow_symlinks": true,
"path": "."
}
],
"build_systems":
[
{
"name":"my_flask_env",
"cmd":["python","-u","$file"],
"path":"/myproject/venv/bin:$PATH",
"file_regex":"^[ ]*File \"(...*?)\", line ([0-9]*)",
"env":{
"PYTHONIOENCODING":"utf8",
"PYTHONHOME":"",
},
"selector": "source.python"
}
]
}
the code of test.py:
import sys,os,flask
print(sys.executable)
#print(inspect.getsoutcefile(flask))
when i run test.py ,the error like this:
ImportError: No module named site
[Finished in 0.0s with exit code 1]
[cmd: ['python', '-u', '/home/bole/myproject/flask_test/test.py']]
[dir: /home/bole/myproject/flask_test]
[path: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin]
So,What should I do now that it will work properly .
My English just so so,i hope it's clear.
Using Terminus and Virtualenv in Sublime Text 3 can be easy. Virtualwrapper is installed and outside Sublime I am using 'workon myenv'. Workon can be used in a sublime-build. My venv is called boringStuff.
{
"target": "terminus_exec",
"cancel": "terminus_cancel_build",
"shell_cmd": "workon boringStuff;python3 -u \"$file\"",
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"working_dir": "$file_path",
"selector": "source.python",
"env": {"PYTHONIOENCODING": "utf-8"},
}
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.