Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
How to use VENV or virtualenv in Pythonista
-
Hi All,
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) -
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-packages
don't affect iOS, and you can't damage your Pythonista installation unless you try really hard. There's no risk in installing modules into thesite-packages
folder provided by Pythonista.Also, both Python's built-in
venv
module and the externalvirtualenv
module 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. Thepython
command 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 realsh
orbash
, and doesn't emulate every behavior perfectly. It's unlikely that the scripts created byvenv
/virtualenv
would work under Stash. -
Eyy I had similar issues, folowing this guide help me a lot to understand about virtualenvs and python