How to use VENV or virtualenv in Pythonista
DaddyCakes last edited by
I'm starting to study Python and Web Development.
I have read a couple of useful articles about flask and so I want to focus on this one.
I already have a Stash on my Pythonista app. However, I am having a hard time creating a virtual environment in the app.
I noticed that Stash does not install pyvenv when I execute this command in Stash:
pip install pyvenv
The error message says it cannot find the module.
And so I proceeded with installing virtualenv
pip install virtualenv
After this, the installation seemed to be complete. However, if I execute the virtualenv in Stash:
python -m virtualenv mytestsite
I'm having an error as follows:
PYTHONHOME is set. You must activate the virtualenv before using it
stash: <clas 'distutils.errors.DistutilsPlatformError'>: invalid Python installation: unable to open /var/conatiners/Bundle/Application/8E7DC623-A2AA-4934-8775-661E7100AFBD/Pythonista3.app/Frameworks/PythonistaKit.framework/pylib/lib/python2.7/config/Makefile (No such file or directory)
dgelessus last edited by
Virtual environments only really make sense when you want to have mutliple Python environments, without affecting an exising Python installation that you don't want to or cannot modify. In Pythonista this is not really necessary, whatever modules you install into
site-packagesdon't affect iOS, and you can't damage your Pythonista installation unless you try really hard. There's no risk in installing modules into the
site-packagesfolder provided by Pythonista.
Also, both Python's built-in
venvmodule and the external
virtualenvmodule rely on copying the Python binary to the virtual environment, and use relatively advanced shell scripts to "activate" and "deactivate" environments. Both will not work under Stash. The
pythoncommand provided by Stash is written in Python like all other Stash commands, it's not a native binary and does not spawn a fully separate process (iOS apps cannot spawn processes). And while Stash supports many important shell features, it is not a real
bash, and doesn't emulate every behavior perfectly. It's unlikely that the scripts created by
virtualenvwould work under Stash.
besti last edited by
Eyy I had similar issues, folowing this guide help me a lot to understand about virtualenvs and python