Python Forum
Can't decide - install modules with Ubuntu package manager (apt) or pip3 in venv
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can't decide - install modules with Ubuntu package manager (apt) or pip3 in venv
#1
Hello python community,

I'm a relative noob in linux (Ubuntu) and python who needs to downclock my gpu using WattmanGTK: https://github.com/BoukeHaarsma23/WattmanGTK, that requires matplotlib, setuptools, python3-gi, and python-3 cairo. This is also my first time installing something like this in this way from github.

I've read extensively over the past couple of days, enough to understand the general differences between using apt (Ubuntu package manager) and pip and the utility of venv. However I have no experience and knowledge as reference to make a judgement call on whether it's only necessary for me to simply install the modules with apt or if it's worthwhile and I'm better off installing them with pip3 in a venv to avoid any potential future version or dependency conflicts, the likelihood of which I'm unsure of since being new to linux, I don't know what are the chances that I will need to use another program which requires conflicting versions or dependencies.

So my main question is:

1. Should I use apt - Ubuntu's package manager to install the modules globally, or pip3 to install the modules in a venv, and why?

I have a few follow up questions, if you don't mind answering, to clarify if I'm understanding correctly:

2. My understanding is that as long as you avoid giving pip root access - sudo pip in Ubuntu - you will avoid the possibility of inadvertently altering system files and breaking the OS. Is this correct?

3. My understanding is that venv is the only way to avoid conflicts. Installing different versions in root (sudo apt) and in a non-root directory (pip -user) both provide global access and does not avoid conflicts. Is this correct?

4. This may seem obvious but I just want to be sure: If I were to install the modules in a venv, I assume that I will have to clone the repository for the program (WattmanGTK), install it and run it from in the venv. Is this right? This bring me to the last question:

5. With reference to Q4, is there a way to access a graphical interface of the venv through the file manager so you can actually see what files are in it. i.e. could I see the repository for the program after putting it in the venv? Or is it only possible to access and interact with the files in venv through command line?

Thank you very much in advance.
Reply
#2
If from PyPi, use pip otherwise apt-get
Reply
#3
I usually install globally and never use virtual environments. That is because my linux partitions are repetitively deleted with a new installation of a distribution quite often. So i have no comment on their use as i never use them.

It should be noted that pip3 does not instantaneously install it to a virtual environment. If your not in one, then it will install to your OS python. You should always use pip to install to python in today's world.

If you plan on using different programs with different dependencies of the same python version, then you might want to use virtual environments, as its easier to handle a multitude of them. But if your just starting out learning its a smaller chance that you would need it. It really depends on what you are doing though.

I would also be more inclined to use virtual environments in Windows as opposed to linux. Especially in a distribution that is not a rolling release. As the slate is wiped clean every install. But again, that depends on what your actually doing.

These questions should be answered on our tutorial. If not, then it should be added.
Recommended Tutorials:
Reply
#4
Thanks for the feedback metulburr.

(Jul-19-2019, 02:54 PM)metulburr Wrote: I usually install globally and never use virtual environments. That is because my linux partitions are repetitively deleted with a new installation of a distribution quite often. So i have no comment on their use as i never use them.

If you're frequently deleting and installing distros, it's fair enough that you install globally since you're less likely to run into conflicts. I don't have any intention of reinstalling Ubuntu or changing distros for the meantime until I get a new pc, which hopefully will happen within the next year.

(Jul-19-2019, 02:54 PM)metulburr Wrote: If you plan on using different programs with different dependencies of the same python version, then you might want to use virtual environments, as its easier to handle a multitude of them. But if your just starting out learning its a smaller chance that you would need it. It really depends on what you are doing though.

And this is the crux of my difficulty. Since I'm new to linux and python, I have no idea how likely it is that I will need to use other programs with conflicting dependencies. For now, I just want WattmanGTK to work so I can downclock my gpu. If installing it with a venv avoids future problems, then great, but for all I know, I may not even use any programs that cause conflict and I'd just be overcomplicating things with venv for nothing.
Reply
#5
If your just planning for WattmanGTK, then i wouldnt bother with virtual environments until you need it. You can always uninstall it later if you use virtual environments later on. Thats my opinion though.
Recommended Tutorials:
Reply
#6
Thanks for sharing metulburr.
Reply
#7
(Jul-19-2019, 03:55 PM)Thisisaline Wrote: I may not even use any programs that cause conflict and I'd just be overcomplicating things with venv for nothing.
Yes you should just try,pip can also uninstall.
Virtual environment is build into Python newer version,so it easy to try that first.
It work for me if i do a quick test,don't find GPU as i now run Virtual-box.
# Make environment 
tom@tom-VirtualBox:~/Documents$ python -m venv watt_env

# Cd in
tom@tom-VirtualBox:~/Documents$ cd watt_env/

# Activate 
tom@tom-VirtualBox:~/Documents/watt_env$ source bin/activate

# Test pip,it point to this folder as it should
(watt_env) tom@tom-VirtualBox:~/Documents/watt_env$ pip -V
pip 19.0.3 from /home/tom/Documents/watt_env/lib/python3.7/site-packages/pip (python 3.7)

# Clone Repo
(watt_env) tom@tom-VirtualBox:~/Documents/watt_env$ git clone https://github.com/BoukeHaarsma23/WattmanGTK.git
Cloning into 'WattmanGTK'...
remote: Enumerating objects: 6, done.
remote: Counting objects: 100% (6/6), done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 753 (delta 0), reused 1 (delta 0), pack-reused 747
Receiving objects: 100% (753/753), 578.10 KiB | 1.14 MiB/s, done.
Resolving deltas: 100% (487/487), done.
(watt_env) tom@tom-VirtualBox:~/Documents/watt_env$ cd WattmanGTK/
(watt_env) tom@tom-VirtualBox:~/Documents/watt_env/WattmanGTK$ ls
LICENSE  README.md  run.py  setup.py  WattmanGTK

# Test Python
(watt_env) tom@tom-VirtualBox:~/Documents/watt_env/WattmanGTK$ python -V
Python 3.7.3

# Run install
(watt_env) tom@tom-VirtualBox:~/Documents/watt_env/WattmanGTK$ python setup.py install
running install ....
A couple of error,need to install this.
sudo apt-get install libcairo2-dev
sudo apt install libgirepository1.0-de
Run install again.
(watt_env) tom@tom-VirtualBox:~/Documents/watt_env/WattmanGTK$ python setup.py install
.....
Using /home/tom/Documents/watt_env/lib/python3.7/site-packages
Finished processing dependencies for WattmanGTK==0.0.1
Quote:Installing different versions in root (sudo apt) and in a non-root directory (pip -user) both provide global access and does not avoid conflicts. Is this correct?
If using pyenv Simple Python Version Management you safer from start,as it never mess with system install of Python.
It dos install Python version wanted(eg 3.7) and make it a system wide installation.
If all goes wrong just go back to local system pyenv local system.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  my venv is not loading njoki 1 178 Mar-20-2024, 10:41 AM
Last Post: snippsat
  problem install somewhere package akbarza 1 429 Dec-27-2023, 01:25 PM
Last Post: Gribouillis
  Not able to install package caldwellpy and requirement txt file Samta282006 1 669 Dec-07-2023, 11:59 PM
Last Post: Larz60+
  Understanding venv; How do I ensure my python script uses the environment every time? Calab 1 2,155 May-10-2023, 02:13 PM
Last Post: Calab
  Confused over Conda Package manager vs PIP JanOlvegg 3 1,161 Mar-09-2023, 02:09 PM
Last Post: JanOlvegg
  Python venv and PIP version issue JanOlvegg 2 1,199 Feb-22-2023, 02:22 AM
Last Post: JanOlvegg
  Visual Studio Code venv ibm_db error mesi1000 7 2,660 Nov-13-2022, 12:36 AM
Last Post: snippsat
  ModuleNotFoundError: No module named '_struct' when starting pip3 yuhuihu 0 2,804 May-05-2022, 04:41 AM
Last Post: yuhuihu
  can not install pymesh in ubuntu jerry 2 2,086 Mar-23-2022, 02:04 AM
Last Post: jerry
  cmake and pip3 install warnings with python 3.10.2 cyrduf 0 1,840 Feb-26-2022, 01:08 PM
Last Post: cyrduf

Forum Jump:

User Panel Messages

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