I'm in #python hell:

root ~ # /usr/local/bin/twine --version
twine version 1.15.0


user ~ # /usr/local/bin/twine --version
twine version 1.9.1

Same computer, new shells.

@publicvoit what does `which python` or `which python3` say in both cases?


@fabian @publicvoit πŸ‘† Yeah, seems like root must be using a different python environment somehow. I've gotten in the habit of setting up a dedicated environment for every new project:

`python3 -m venv /path/to/my/proj/dir/venv`

(Can put it anywhere, proj. dir is just handy) which can then be activated with

`source /path/to/my/proj/venv/bin/activate`

That way anything you install with pip will be self-contained and avoid version problems. (To exit you can just type `deactivate`)

Β· Web Β· 1 Β· 0 Β· 0

@ItsTheManOnTheMoon @fabian Is "python3 -m venv" the same as "virtualenv venv"?
Can the venv-dir itself be a subdir of the source dir so that it doesn't mess up my PROJECT/bin/ dir?
Do I have to re-activate the env (after reboot)?
How am I able to use the venv in cronjobs that are calling the python files?

@publicvoit @fabian Ah, it does look like virtualenv is the same thing. The venv dir can go anywhere, and you would need to re-activate it any time you want to work on that project. (Most IDEs will also let you specify the environment for the project too.)

I haven't tested to confirm, but for cron I think you just invoke the venv python directly (stackoverflow.com/a/3287063)

* * * * * cd /path/to/my/project && /path/to/my/venv/bin/python mycode.py

Sign in to participate in the conversation

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!