Feb-20-2023, 10:06 PM
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.
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.