5 ms·
Basically it seems you are lacking only two shell commands. virtualenv venv . venv/bin/activate Then everything works with pip pip install numpy
by wirrbel 8y ago
Basically it seems you are lacking only two shell commands.
virtualenv venv
. venv/bin/activate
Then everything works with pip
pip install numpy
I actually prefer the pipenv way (or the virtualenvwrapper way) of putting virtualenvs into a dedicated location, so that I can wipe them off the hard disk if I want to free some space.
The real interesting and occasionally bothering point on managing your virtualenv is resolution of dependencies and compatibility ranges (hard to solve in general).
- icebraining 8y agoAt a previous job, we used an even simpler solution: just download everything to a directory (called "deps") with pip install --target deps -r requirements.txt Then running the application with PYTHONPATH=deps python myapp.py This was also simple to integrate with service supervisors, since most make it easy to configure a environment variable.
- jazzyjackson 8y agoMaking a note of this, didn't know about the target flag, thanks !
- ProblemFactory 8y agoVirtualenv tip: you can skip the Bash magic of calling "activate" by providing the path to the python executable. /hello/venvs/myproject/bin/python myscript.py will run myscript.py exactly as if the virtualenv was active, which is easier to configure for cron jobs and services.
- wirrbel 8y agoIf this works for you, good. I think I would be cautious giving this out as advice because you can run into problems this way with regards to different python versions. The activate script uses the python version used to setup the environment.
- chatmasta 8y agoThis doesn’t address his problem of dependencies being “halfway across my computer.”
- Dylan16807 8y agoYes it does. Everything is installed in the venv folder. To start fresh you just delete it [and restart bash].
- chatmasta 8y agoThat's true, but I assumed GP was referring to the fact that venvs are kept in a global, e.g. $HOME/.venvs, rather than in $(pwd)/.venv like $(pwd)/node_modules.
- deleted 8y ago[deleted]
- Dylan16807 8y agoIf you're using the commands in that post, the venv won't be kept in a global location.
- jessaustin 8y agoThose shell commands don't do anything to publish a package, do they? Sorry, python is still lacking quite a bit of what e.g. js with npm has had for years.