Python Forum
A question about setting up Python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A question about setting up Python
#1
Hi, I am new to Python development and have a question about setting up the python development and best practices. I currently have Python install on my linux desktop (PopOS). The python version installed with the OS is 3.10.6. My question is how best to setup the python development environment?

Based on reading, I was thinking of doing the following.
1. Create a project folder for the project.
2. Using python venv, create a venv folder in the project (using the python3 -m venv)
3. Activate the virtual environment.

On several online post, it said not to include the venv in the source control. Should I follow this advise? I was thinkng that I would probably need to duplicate this setup across different team members. Having that venv in github might be helpful or should we just check requirements.txt into the source control and have the other developers use requirements.txt to create the venv if that is possible?

I am also thinking that we need to specify specific package version in the requirements.txt, using ==.

From what I can gather, the venv will only allow virtual package version, the python version remained fixed. I couldn't use venv for example to create an environment for Python 3.9 when I am using Python 3.10? How important is these minor differences in version. This is because it is likely that the other team members might not use the same python version or the same OS, though the python version might be just minor revision differences. Because I am just starting out, I was trying to avoid having multiple version installed on the same box. The other reason is that a lot of Linux seems to use Python, so changing the version might cause an issue.

One more question is regarding admin rights and packages. I got the impression that the main Python and PIP itself should probably be installed with admin rights (sudo on Linux), but pip packages should not be install without admin rights. I notice that when I experimented with pip install with admin rights, I get a warning message suggesting that it will break pip, but if I use pip without admin, I get a message that it can't write to admin directory. I am a bit confused but feel that running PIP install using admin seemes risky since I don't know if the package will contain malware. Should I use pip install --user?

Sorry for all of the questions, I would appreciate guidance for someone starting out in Python.
Reply
#2
Do not include venv in source control. If you want to make it easy to duplicate your setup, make a requirements.txt file that lists all the packages to install. Pip will make the file for you.

pip freeze > requirements.txt

To restore

pip install -r requirements.txt
ndc85430 and jefsummers like this post
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Setting up new Python kernel for JupyterLab Desktop on M1 Mac daler6 0 1,330 Jun-20-2022, 03:45 AM
Last Post: daler6
  Advice on Setting Up the Python Environment punksnotdead 1 2,437 May-15-2019, 04:29 PM
Last Post: snippsat
  Setting DCHP in Windows 10 with Python Martin2998 4 3,733 Dec-07-2018, 10:15 PM
Last Post: Martin2998
  Setting up Python on a Mac - Beginner BrowneyesPage1979 1 2,488 Aug-30-2018, 10:41 PM
Last Post: snippsat
  Setting up python with visual studio code. Having one issue. xringo 2 3,829 May-21-2018, 12:09 AM
Last Post: snippsat
  setting evironment of Linux using python kgkhan 2 4,897 Dec-06-2016, 02:27 PM
Last Post: kgkhan

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020