Sample Header Ad - 728x90

Unix & Linux Stack Exchange

Q&A for users of Linux, FreeBSD and other Unix-like operating systems

Latest Questions

1 votes
1 answers
2626 views
Make Python3 default without breaking yum in RHEL7
> **What specific syntax needs to be changed or added to the below in order for commands calling `python` in a RHEL7 VM to be interpreted using Python3 WITHOUT breaking programs like `yum` that require Python2?** **FIRST ATTEMPT:** Our first attempt was to add the following 2 lines to the very end o...
> **What specific syntax needs to be changed or added to the below in order for commands calling python in a RHEL7 VM to be interpreted using Python3 WITHOUT breaking programs like yum that require Python2?** **FIRST ATTEMPT:** Our first attempt was to add the following 2 lines to the very end of the cloud-init startup script which instantiates the VM: rm /usr/bin/python ln -s /usr/bin/python3 /usr/bin/python **ERROR THAT RESULTED:** The problem is that adding the above two lines to the end of the cloud-init startup script causes yum commands to break when yum is called afterwards as follows: $ sudo yum update -y File "/bin/yum", line 30 except KeyboardInterrupt, e: ^ SyntaxError: invalid syntax $ **TOGGLING THE ERROR:** We can turn off the error by removing the above 2 lines from the cloud-init startup script and re-instantiating a new replacement VM. This isolates the source of the problem, but still we have the problem of how to default python to Python3 without breaking apps like yum.
CodeMed (5357 rep)
Jul 7, 2020, 05:24 PM • Last activity: Jul 27, 2025, 02:04 AM
4 votes
1 answers
3554 views
Finding which specific Python process was killed by Linux OOM killer
I'm trying to figure out which specific Python process or executable was killed by the Linux OOM killer. In /var/log/messages I get this: Aug 18 03:19:11 169 kernel: [ 7747] 0 7748 3226957 2875051 5692 0 0 python (notice it just say name = "python") and this: Aug 18 03:19:11 169 kernel: Killed proce...
I'm trying to figure out which specific Python process or executable was killed by the Linux OOM killer. In /var/log/messages I get this: Aug 18 03:19:11 169 kernel: [ 7747] 0 7748 3226957 2875051 5692 0 0 python (notice it just say name = "python") and this: Aug 18 03:19:11 169 kernel: Killed process 7748 (python) total-vm:12907828kB, anon-rss:11500204kB, file-rss:0kB (again notice it just says the process was "python") Ideally a log file for the process would have the PID somewhere. But suppose the logs wrapped (or suppose the process doesn't log the PID anywhere). Does Linux provide a way to figure out the full command that was executed for the process? It would be nice to configure Linux's OOM killer to display the full name in the process table, such as: /usr/bin/python /usr/lib/python2.7/site-packages/foo.pyc Or maybe at the time of the OOM error Linux stores off some of the process details somewhere? i.e. copy the processes from /proc to X? (wishful thinking) ### NOTE: ### This question is very similar to this question: https://stackoverflow.com/questions/624857/finding-which-process-was-killed-by-linux-oom-killer But it fell short of what I'm trying to figure out.
jersey bean (553 rep)
Aug 18, 2017, 09:32 PM • Last activity: Jul 20, 2025, 12:08 PM
2 votes
1 answers
7954 views
How to fix error: "symbol lookup error: /usr/local/lib/libQt5DBus.so.5: undefined symbol"?
I was using GNS3 network simulator fine for a while & then after few days When I start GNS3 Network Simulator, it is giving out following error, not sure what caused this. **$ sudo gns3** GNS3 GUI version 1.5.2 Copyright (c) 2007-2016 GNS3 Technologies Inc. your locale en_IN.ISO8859-1 encoding is no...
I was using GNS3 network simulator fine for a while & then after few days When I start GNS3 Network Simulator, it is giving out following error, not sure what caused this. **$ sudo gns3** GNS3 GUI version 1.5.2 Copyright (c) 2007-2016 GNS3 Technologies Inc. your locale en_IN.ISO8859-1 encoding is not UTF-8, switching to the UTF-8 version... 2016-12-23 22:57:53 INFO logger.py:107 Log level: INFO /usr/share/gns3/gns3-gui/bin/python: symbol lookup error: /usr/local/lib/libQt5DBus.so.5: undefined symbol: _Z28qEnvironmentVariableIntValuePKcPb I tried reinstalling gns3 but the error persisted. While Un-installing, I got the following warnings: dpkg: warning: while removing gns3-gui, directory '/usr/share/gns3/gns3-gui/lib/python3.4/__pycache__' not empty so not removed dpkg: warning: while removing gns3-gui, directory '/usr/share/gns3/gns3-gui/bin' not empty so not removed Removing gns3-server (1.5.2~trusty1) ... dpkg: warning: while removing gns3-server, directory '/usr/share/gns3/gns3-server/lib/python3.4/__pycache__' not empty so not removed dpkg: warning: while removing gns3-server, directory '/usr/share/gns3/gns3-server/bin' not empty so not removed So I removed /usr/share/gns3* and then tried installing GNS3 no luck. Tried the following suggestions made in this answer Commented the line "/usr/local/lib" in the file /etc/ld.so.conf.d/libc.conf but no use. Also when I tried installing GNS3 through Ubuntu Software Center enter image description here
karthik v (133 rep)
Dec 23, 2016, 05:35 PM • Last activity: Jun 29, 2025, 08:03 PM
3 votes
1 answers
4132 views
How to change the default (binary) python version in a FreeBSD jail?
In a jail, I have installed `python3.6` along `python3.4`. Both were installed using `pkg install`, no ports. I want to keep the 3.4 version for some time, but set the 3.6 as default. Answers found in internet, like [this one](https://stackoverflow.com/questions/9349831/how-to-set-python-version-by-...
In a jail, I have installed python3.6 along python3.4. Both were installed using pkg install, no ports. I want to keep the 3.4 version for some time, but set the 3.6 as default. Answers found in internet, like [this one](https://stackoverflow.com/questions/9349831/how-to-set-python-version-by-default-in-freebsd) or [this one](https://unix.stackexchange.com/questions/254660/freebsd-using-python3-in-uwsgi-instead-of-python2) either involve to myself link /usr/local/bin/python to python3.6 (what must be done again after any upgrade of the default python, what I'd like to avoid; plus there's no such link anyway); or to set DEFAULT_VERSIONS in /etc/make.conf, what has no effects on binaries installation (I've tried, nevertheless). Moreover, the virtual environment is not an option, since I want to run uwsgi, what requires the *system wide* default python to match the one in the python virtual environment of the python application it "monitors" (in my case, Django), in order to start correctly. Even if I start from inside the Django's virtual environment (providing python3.6), uwsgi detects python3.4 as the default python version. Cannot find if there is any environment variable missing neither. For information, inside the jail (and virtual environment): # printenv USER=root LOGNAME=root HOME=/root SHELL=/bin/csh BLOCKSIZE=K MAIL=/var/mail/root PATH=/usr/local/venv/dj1/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/root/bin TERM=xterm-256color HOSTTYPE=FreeBSD VENDOR=amd OSTYPE=FreeBSD MACHTYPE=x86_64 SHLVL=1 PWD=/var/log GROUP=wheel HOST=dev_web0 EDITOR=vi LANG=fr_FR.UTF-8 MM_CHARSET=UTF-8 PAGER=more VIRTUAL_ENV=/usr/local/venv/dj1
zezollo (141 rep)
May 3, 2017, 02:52 PM • Last activity: Jun 27, 2025, 08:04 AM
0 votes
0 answers
25 views
Is the are a single site-packages directory for multiple versions of python3 in rpm-based distros?
I am working on creating deb/rpm packages for [a little project of mine][1]. [1]: https://github.com/eantoranz/rebase-- I have already created the packages for a few rpm-based and deb-based distros. In deb distros one python file is being setup in `/usr/lib/python3/dist-packages/`. In rpm-based dist...
I am working on creating deb/rpm packages for a little project of mine . I have already created the packages for a few rpm-based and deb-based distros. In deb distros one python file is being setup in /usr/lib/python3/dist-packages/. In rpm-based distros, I have to first detect the version of python being used when building and then I can set it up at the right directory. So, for rockylinux 9, I use /usr/lib64/python3.9/site-packages, for fedora 42 I use /usr/lib64/python3.13/site-packages. It works! However, I just realized that because on rpm distros the file is located in a python-version-dependent directory established when I am packaging it, if on the box it will run python is updated to a newer version from the one I used by default on that distro during packaging-time, it will break. Is there a more python-minor-version independent directory that could be used in rpm-based distros? I don't want to add the file in multiple places just so that it is available in all the python versions that could be installed from distro packages.
eftshift0 (707 rep)
Jun 22, 2025, 10:14 PM
0 votes
1 answers
117 views
Systemd fails to restart a Python script with exit(0)
I have a working python script and systemd service script. But somehow it is not working the way I wanted it. The python script prints time every 5s but stops with exit(0) at first second of a minute. This is fine. The systemd seems to be working fine for the first time. Once the python script stops...
I have a working python script and systemd service script. But somehow it is not working the way I wanted it. The python script prints time every 5s but stops with exit(0) at first second of a minute. This is fine. The systemd seems to be working fine for the first time. Once the python script stops, it fails to restart. My python script: test_python_script_auto_run_linux_raspberrypi.py from datetime import datetime import schedule def print_time_now(): time_now = datetime.now() print("%s : This is the time now"%(time_now)) def stop_the_script(): time_now = datetime.now() print("%s : Stopping the script ..."%(time_now)) # Clean exit with no errors exit(0) schedule.every(5).seconds.do(print_time_now) schedule.every().minute.at(":01").do(stop_the_script) while True: schedule.run_pending() sudo nano /etc/systemd/system/testpythonpcriptautorunmm.service [Unit] Description=Testing my python script for auto restart After=multi-user.target [Service] Type=simple Restart=always RestartSec=60 ExecStart=/usr/bin/python3 /home/pi/Documents/RaspberryPi_projects/ExamplEScripts_Practice_MM_20221209/test_python_script_auto_run_linux_raspberrypi.py [Install] WantedBy=multi-user.target Terminal commands: pi@raspberrypi:~ $ sudo systemctl status testpythonpcriptautorunmm.service ● testpythonpcriptautorunmm.service - Testing my python script for auto restart Loaded: loaded (/etc/systemd/system/testpythonpcriptautorunmm.service; enabled; vendor preset: enabled) Active: inactive (dead) since Wed 2024-06-19 12:38:01 EDT; 40s ago Process: 816 ExecStart=/usr/bin/python3 /home/pi/Documents/RaspberryPi_projects/ExamplEScripts_Practice_MM_20221209/test_python_script_auto_run_linux_raspberrypi.py (code=exited, status=0/SU Main PID: 816 (code=exited, status=0/SUCCESS) Jun 19 12:37:12 raspberrypi systemdReferenced image: Started Testing my python script for auto restart. Jun 19 12:38:01 raspberrypi python3: 2024-06-19 12:37:17.883550 : This is the time now Jun 19 12:38:01 raspberrypi python3: 2024-06-19 12:37:57.454879 : This is the time now Jun 19 12:38:01 raspberrypi python3: 2024-06-19 12:38:01.000049 : Stopping the script ... Jun 19 12:38:01 raspberrypi systemdReferenced image: testpythonpcriptautorunmm.service: Succeeded. lines 1-11/11 (END) When I run the python script on same raspberry pi using Thonny IDE: enter image description here What could be the problem? Why does the systemd service fail to restart the script after a successful first run? **Edit:** Updated systemd service: [Unit] Description=Testing my python script for auto restart After=multi-user.target [Service] Type=simple Restart=always #on-failure#always RestartSec=10 WatchdogSec=60 ExecStart=/usr/bin/python3 /home/pi/Documents/RaspberryPi_projects/ExamplEScripts_Practice_MM_20221209/test_python_script_auto_run_linux_raspberrypi.py RemainAfterExit=yes [Install] WantedBy=multi-user.target Terminal response: pi@raspberrypi:~ $ sudo nano /etc/systemd/system/testpythonpcriptautorunmm.service pi@raspberrypi:~ $ sudo systemctl status testpythonpcriptautorunmm.service ● testpythonpcriptautorunmm.service - Testing my python script for auto restart Loaded: loaded (/etc/systemd/system/testpythonpcriptautorunmm.service; enabled; vendor preset: enabled) Active: active (exited) since Wed 2024-06-19 13:07:22 EDT; 4min 6s ago Process: 1621 ExecStart=/usr/bin/python3 /home/pi/Documents/RaspberryPi_projects/ExamplEScripts_Practice_MM_20221209/test_python_script_auto_run_linux_raspberrypi.py (code=exited, status=0/S Main PID: 1621 (code=exited, status=0/SUCCESS) Jun 19 13:07:22 raspberrypi systemdReferenced image: Started Testing my python script for auto restart. Jun 19 13:08:01 raspberrypi python3: 2024-06-19 13:07:27.438964 : This is the time now Jun 19 13:08:01 raspberrypi python3: 2024-06-19 13:07:32.439073 : This is the time now Jun 19 13:08:01 raspberrypi python3: 2024-06-19 13:07:37.439153 : This is the time now Jun 19 13:08:01 raspberrypi python3: 2024-06-19 13:07:42.439228 : This is the time now Jun 19 13:08:01 raspberrypi python3: 2024-06-19 13:07:47.439308 : This is the time now Jun 19 13:08:01 raspberrypi python3: 2024-06-19 13:07:52.439386 : This is the time now Jun 19 13:08:01 raspberrypi python3: 2024-06-19 13:07:57.439471 : This is the time now Jun 19 13:08:01 raspberrypi python3: 2024-06-19 13:08:01.000031 : Stopping the script ... pi@raspberrypi:~ $ As per this new update, the script seems to be active after 4 minutes of operation but failed to run the script. Don't know why?
Mainland (115 rep)
Jun 19, 2024, 04:20 PM • Last activity: Jun 5, 2025, 06:32 AM
17 votes
6 answers
7140 views
Change location of `~/.python_history`
I want to keep the functionality, but change the location of `~/.python_history` to `$XDG_DATA_HOME/python/python_history`. [This](https://unix.stackexchange.com/a/297834/282466) gave me the following idea: I could create `$XDG_CONFIG_HOME/python/pythonrc` and point `$PYTHONSTARTUP` to it. In there...
I want to keep the functionality, but change the location of ~/.python_history to $XDG_DATA_HOME/python/python_history. [This](https://unix.stackexchange.com/a/297834/282466) gave me the following idea: I could create $XDG_CONFIG_HOME/python/pythonrc and point $PYTHONSTARTUP to it. In there I want to replace the functions readline.read_history_file, readline.write_history_file and readline.append_history_file. Is there way to replace these functions with themselves, containing a custom filename argument? If not, do you have another idea how to approach this?
maddingl (686 rep)
Jan 23, 2021, 11:06 PM • Last activity: Jun 1, 2025, 10:09 PM
1 votes
3 answers
4975 views
How do I force Pycharm to recognize and use Python 3.6.1 libraries?
Same as above. Recently I broke my system and then wiped and reinstalled. I initially managed to get python 3.6 working in Pycharm with a new installed before breaking things again. I didn't do anything special and merely retraced my steps only to find Pycharm only seeing 2.7 and 3.5 instead of 3.6...
Same as above. Recently I broke my system and then wiped and reinstalled. I initially managed to get python 3.6 working in Pycharm with a new installed before breaking things again. I didn't do anything special and merely retraced my steps only to find Pycharm only seeing 2.7 and 3.5 instead of 3.6 on my 3rd install. I want to make use of the most current version of Python due to the features it's released. How do I set up environment variables to recognize 3.6.1 for development purposes? I did it a few times on Windows but merely went into Advanced system settings and added a few lines in a window. I installed Python 3.6.1 successfully on Mint; How can I duplicate the above process for Pycharm on Linux?
Lusus Naturae (77 rep)
Jun 3, 2017, 09:19 AM • Last activity: May 29, 2025, 01:01 AM
0 votes
1 answers
3834 views
Python3.6's Pip Checking wrong Python Version
I've recently upgraded to use Python 3.6 on Ubuntu 16.04. Now I have Python 2.7, 3.5, and 3.6 all on the same system. I've had pip (defaults to v2.7), and pip3 (defaults to v3.5), and I then reinstalled pip3 according to this link: https://stackoverflow.com/a/44254088/3123703 . I'm now on the path t...
I've recently upgraded to use Python 3.6 on Ubuntu 16.04. Now I have Python 2.7, 3.5, and 3.6 all on the same system. I've had pip (defaults to v2.7), and pip3 (defaults to v3.5), and I then reinstalled pip3 according to this link: https://stackoverflow.com/a/44254088/3123703 . I'm now on the path to installing all the libraries I'm using for the new Python 3.6. But for some reason, pip3.6 is checking for the libraries in Python 3.5 folders: $ sudo pip3.6 install numpy Requirement already satisfied: numpy in /usr/local/lib/python3.5/dist-packages Also: $ pip3 --version pip 9.0.1 from /home//.local/lib/python3.6/site-packages (python 3.6) $ pip3.6 --version pip 9.0.1 from /home//.local/lib/python3.6/site-packages (python 3.6) Is there a way to get pip3.6 to not look in the Python 3.5 folders? Or do I have to completely uninstall Python 3.5 and Python 3.6 and start from scratch? FYI, I'm not asking for a specific package, as numpy was just an example here.
nfmcclure (101 rep)
Jun 20, 2017, 06:06 PM • Last activity: May 23, 2025, 09:02 AM
1 votes
1 answers
2967 views
Cannot install pyqt5
I'm trying to install pyqt5 and I'm getting the following error : $ sudo pip3 install pyqt5 Collecting pyqt5 From cffi callback : Traceback (most recent call last): File "/usr/local/lib/python3.6/dist-packages/OpenSSL/SSL.py", line 313, in wrapper _lib.X509_up_ref(x509) AttributeError: module 'lib'...
I'm trying to install pyqt5 and I'm getting the following error : $ sudo pip3 install pyqt5 Collecting pyqt5 From cffi callback : Traceback (most recent call last): File "/usr/local/lib/python3.6/dist-packages/OpenSSL/SSL.py", line 313, in wrapper _lib.X509_up_ref(x509) AttributeError: module 'lib' has no attribute 'X509_up_ref' Could not find a version that satisfies the requirement pyqt5 (from versions: ) No matching distribution found for pyqt5 I have no idea how to tackle this one anymore. My Os : Linux version 4.13.0-38-generic (buildd@lgw01-amd64-042) (gcc version 7.2.0 (Ubuntu 7.2.0-8ubuntu3.2)) #43-Ubuntu SMP Wed Mar 14 15:20:44 UTC 2018 I've got python 2.7.14 and python 3.6.3
Gabriel Lafayette (71 rep)
Apr 6, 2018, 07:41 PM • Last activity: May 7, 2025, 10:01 AM
36 votes
9 answers
16147 views
Is there something wrong with my script or is Bash much slower than Python?
I was testing the speed of Bash and Python by running a loop 1 billion times. $ cat python.py #!/bin/python # python v3.5 i=0; while i<=1000000000: i=i+1; Bash code: $ cat bash2.sh #!/bin/bash # bash v4.3 i=0 while [[ $i -le 1000000000 ]] do let i++ done Using the `time` command I found out that the...
I was testing the speed of Bash and Python by running a loop 1 billion times. $ cat python.py #!/bin/python # python v3.5 i=0; while i<=1000000000: i=i+1; Bash code: $ cat bash2.sh #!/bin/bash # bash v4.3 i=0 while [[ $i -le 1000000000 ]] do let i++ done Using the time command I found out that the Python code takes just 48 seconds to finish while the Bash code took over 1 hour before I killed the script. Why is this so? I expected that Bash would be faster. Is there something wrong with my script or is Bash really much slower with this script?
Alex Jones (6483 rep)
Aug 13, 2016, 08:43 AM • Last activity: Apr 18, 2025, 09:51 AM
0 votes
0 answers
34 views
php script: shell_exec('nohup /usr/bin/python3 -u /location/script.py > /location/script.log & : Script terminates after 5 seconds but should not
I have a PHP Script with the command `shell_exec('nohup /usr/bin/python3 -u /location/script.py > /location/script.log &');` This PHP Script is called via ajax, the script runs, logfile is created, output is written to logfile, but the python script terminates after 5-6 seconds. The same command run...
I have a PHP Script with the command shell_exec('nohup /usr/bin/python3 -u /location/script.py > /location/script.log &'); This PHP Script is called via ajax, the script runs, logfile is created, output is written to logfile, but the python script terminates after 5-6 seconds. The same command runs flawlessly in a SSH terminal. The PHP is an Ajax-called script, there is no issue with the Ajax call. I can tell because the logfile is created and the first few output lines are correct, but then the python script terminates. Whatever I did, it did not change, I tried prefixing with sudo -u username and sudo -u www-data, appending & disown &, changed the user that runs apache2, but all attempts didn't change the result. The python3 code is working correctly, because i can manually start the command from SSH and it runs flawlessly. There is no stacktrace in the logfile, it just stops. It vanishes from ps aux | grep script I need the Ajax method of calling the script, what can I do? Running on Debian 12
cli (1 rep)
Apr 13, 2025, 02:57 PM • Last activity: Apr 13, 2025, 04:01 PM
0 votes
0 answers
144 views
Installing python 3.12 and pip on Ubuntu 22
Im on Ubnutu 22 and trying to run some python code I developed on my mac which runs python 3.12, Ubuntu 22 comes with python 3.10.x but I cant use that version. Im also using the idle IDE and pip as the package manager. I have been unable to install various packages with pip into python 3.12 because...
Im on Ubnutu 22 and trying to run some python code I developed on my mac which runs python 3.12, Ubuntu 22 comes with python 3.10.x but I cant use that version. Im also using the idle IDE and pip as the package manager. I have been unable to install various packages with pip into python 3.12 because they don't end up in the 3,10 version path. I am concerned about inserting links because they may redirect only a part of the environment and leave me more confused than before. Why is there no simple way for the uninitiated to install python3.xx have the package managers and everything else work without wrestling with all manner of complexities. Is there a simple way to do this ? Thanks
parryj (1 rep)
Feb 25, 2025, 01:33 AM
0 votes
1 answers
473 views
How to upgrade numpy? | ImportError: Matplotlib requires numpy>=1.23; you have 1.21.5
I need to run matplotlib. However, it requires an up-to-date version of `numpy`. How can I manually update my `numpy` installation? ``` $ pip install numpy --upgrade Defaulting to user installation because normal site-packages is not writeable Requirement already satisfied: numpy in /home/n4089/.loc...
I need to run matplotlib. However, it requires an up-to-date version of numpy. How can I manually update my numpy installation?
$ pip install numpy --upgrade
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: numpy in /home/n4089/.local/lib/python3.10/site-packages (2.2.3)
ImportError                               Traceback (most recent call last)
Cell In, line 3
      1 import random,multiprocess,os,json,re
      2 import numpy as np
----> 3 import matplotlib.pyplot as plt

File ~/.local/lib/python3.10/site-packages/matplotlib/__init__.py:264
    259         if parse_version(module.__version__) ={minver}; "
    261                               f"you have {module.__version__}")
--> 264 _check_versions()
    267 # The decorator ensures this always returns the same handler (and it is only
    268 # attached once).
    269 @functools.cache
    270 def _ensure_handler():

File ~/.local/lib/python3.10/site-packages/matplotlib/__init__.py:260, in _check_versions()
    258 module = importlib.import_module(modname)
    259 if parse_version(module.__version__)  260     raise ImportError(f"Matplotlib requires {modname}>={minver}; "
    261                       f"you have {module.__version__}")

ImportError: Matplotlib requires numpy>=1.23; you have 1.21.5
**OS**: PopOS Thank you so much for any help! Feel free to migrate if there is a better Stackexchange for this question. I know there are a few others asking similar questions. Sadly, those appear to be focused on utilizing Python with homebrew.
user2231142 (111 rep)
Feb 16, 2025, 10:41 PM • Last activity: Feb 16, 2025, 10:43 PM
0 votes
0 answers
74 views
Does homebrew and Xcode python share the same environment?
I am trying to flesh-out a mental model of Python environments for my MacBook (MacOS Ventura 12.x). I am aware of venv (virtual environments) and that it serves to prevent updates from changing the venv python3 version and its venv modules (separate configuration management). My Mac is outfitted wit...
I am trying to flesh-out a mental model of Python environments for my MacBook (MacOS Ventura 12.x). I am aware of venv (virtual environments) and that it serves to prevent updates from changing the venv python3 version and its venv modules (separate configuration management). My Mac is outfitted with homebrew: 1) /usr/bin/python3 -V1 returns the **Xcode** Python version: 3.9.6 2) python3 --version or python3 -V returns "Python 3.10.8" 3) brew list | grep python returns: python-packaging python@3.10 python@3.11 python@3.12 python@3.13 mysql-connector-python 4. which python3 returns /usr/local/bin/python3 (Xcode python I presume) 5. brew install python returns: Warning: python@3.13 3.13.1 is already installed, it's just **not linke**d. To link this version, run: brew link python@3.13 Does the Xcode python and homebrew python share the same environment / space or are they somehow separate? If they are separate, how is toggling between the two performed? I ask because I would like to install the pyserial module so that I do not have to use it in a venv and use it with either the Xcode OR the homebrew python (preferable).
gatorback (1522 rep)
Feb 6, 2025, 02:20 AM • Last activity: Feb 6, 2025, 02:58 AM
5 votes
2 answers
5631 views
How to find system language within Python?
Is there any way, in Python 3, to find out the language used by the system? Even a tricky one though, like: reading from a file in a sneaky directory, and finding the string `'ENG'` or `'FRE'` within the file's content…
Is there any way, in Python 3, to find out the language used by the system? Even a tricky one though, like: reading from a file in a sneaky directory, and finding the string 'ENG' or 'FRE' within the file's content…
joH1 (948 rep)
Jul 11, 2016, 10:17 PM • Last activity: Feb 1, 2025, 09:48 PM
0 votes
1 answers
1325 views
I blew up python, pip, and dnf
I bought a book about cyber security in Python, and the author uses python version 3.9. I use Fedora Linux 37 and the default Linux is Linux 3.11. I set up a virtual environment and tried to install the authors' `requirements.txt` packages. The process choked; apparently the new version of python ca...
I bought a book about cyber security in Python, and the author uses python version 3.9. I use Fedora Linux 37 and the default Linux is Linux 3.11. I set up a virtual environment and tried to install the authors' requirements.txt packages. The process choked; apparently the new version of python can't handle retrograde versions of, say, numpy (and other packages). So I did something some may well criticize. I downloaded python 3.9 and compiled and installed it. It appeared to go OK. But then I noticed that both pip and dnf were broken. pip gave me the message:
-shellsession
$ pip install --upgrade pip
Could not find platform dependent libraries 
Consider setting $PYTHONHOME to [:]
Traceback (most recent call last):
File "/usr/bin/pip", line 7, in 
from pip._internal.cli.main import main
ModuleNotFoundError: No module named 'pip._internal'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/bin/pip", line 10, in 
from pip._internal.main import main
ModuleNotFoundError: No module named 'pip._internal'
During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/bin/pip", line 17, in 
from pip._internal import main
ModuleNotFoundError: No module named 'pip._internal'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/bin/pip", line 20, in 
from pip import main
ImportError: cannot import name 'main' from 'pip' (unknown location)
And from dnf:
-shellsession
# dnf install wireshark
Traceback (most recent call last):
File "/usr/bin/dnf", line 61, in 
from dnf.cli import main
ModuleNotFoundError: No module named 'dnf'
Now, call me naive, but I thought one of the rationales for virtual environments was to be able to use different python versions with a particular program. As to what happened to my dnf, I have no clue, but I don't know how to fix it.
Bryan Zimmer (11 rep)
Feb 2, 2023, 11:12 PM • Last activity: Jan 16, 2025, 03:13 PM
-1 votes
1 answers
52 views
How do I install python on cpanel on linux
I am trying to deploy a linux executable from Delphi. 1. The host has cpanel 2. I have installed PAServer 3. However I get this error about symlink target directory does not exist [![enter image description here][1]][1] ``` Unable to start LLDB kernel: ;Symbolic link target does not exist: /home/pac...
I am trying to deploy a linux executable from Delphi. 1. The host has cpanel 2. I have installed PAServer 3. However I get this error about symlink target directory does not exist enter image description here
Unable to start LLDB kernel: ;Symbolic link target does not exist: /home/pacifi85/PAServer-23.0/lldb/lib/libpython3.so -> /usr/lib/x86_64-linux-gnu/libputhon3/7m.so.1.0.

Please make sure that the target exists or update the link to point to the new Python 3 shared object.
--- Looking around the server, x86_64-linux-gnu directory does not exist. So, I am guessing that perhaps python is not installed. I see these files in **usr/lib**
python3.6
 site-packages
   easy_install.py
   pip
   pip-9.0.3.dist-info
   pkg_resources
   __pycache__
   setuptools
   setuptools-39.2.0.dist-info
setuptools has a many .py files. I have searched but I haven't found anything that corresponds to the files I see. How can I install python on it. Notes - cpanel has no menu item to do it. - On other forums I am told to point the symlink to whatever version **.so** there is. - But I cant find the **so** or any path to **x86**. I am coming to the conclusion that either my tool no longer works on ARM or my host no longer uses x86. --- Just finished an hour long session with ISP-support. They insist that python is installed but cant tell me where the library /shared-object is located.
Rohit Gupta (385 rep)
Jan 14, 2025, 03:25 PM • Last activity: Jan 14, 2025, 04:36 PM
0 votes
2 answers
3779 views
Errno 13 Permission denied when pip upgrade or pip install
I have set up my virtual ennvironment and i'm trying to install the package but i keep on running into this error : ```ERROR: Could not install packages due to an OSError: [Errno 13] Permission denied: '/home/daeltam/.MyVenv/lib/python3.11/site-packages/propcache' Check the permissions.``` This happ...
I have set up my virtual ennvironment and i'm trying to install the package but i keep on running into this error :
: Could not install packages due to an OSError: [Errno 13] Permission denied: '/home/daeltam/.MyVenv/lib/python3.11/site-packages/propcache' Check the permissions.
This happens when i run : -
-m pip install discord
-
install discord --user
-
install discord
All of those tests have been made looking at forums. But the majority of them advice to create a virtualenv to fix this, which is already the case for me... Running
sudo pip install --upgrade pip
only gives me this error message i can't understand, no matter if i'm inside the venv or not :
: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
    python3-xyz, where xyz is the package you are trying to
    install.

    If you wish to install a non-Debian-packaged Python package,
    create a virtual environment using python3 -m venv path/to/venv.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
    sure you have python3-full installed.

    If you wish to install a non-Debian packaged Python application,
    it may be easiest to use pipx install xyz, which will manage a
    virtual environment for you. Make sure you have pipx installed.

    See /usr/share/doc/python3.11/README.venv for more information.

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification
I am on debian if this is useful, i'm a newbie regarding linux and permissions are still a little bit obscure for me even after reading articles to understand. **Edit with my progress :** As below comments and answers seem to say, the problem might have been me setting up my venv with sudo during one of my tests. So what i just tried is deleting the venv ( with sudo rm -rf .venv) and then creating one back with python3 -m venv .MyVenv (i prefer that name) But i got this error message once again : Error: [Errno 13] Permission denied: '/home/daeltam/Daeltam/.MyVenv/pyvenv.cfg' I can still activate the Venv with source Path/bin/activate but i haven't made more tests.
Daeltam (13 rep)
Jan 1, 2025, 01:47 PM • Last activity: Jan 14, 2025, 03:25 PM
0 votes
1 answers
35 views
Cant't create a Venv on Debian - No error message
I had my files transferred on another OS (from RetroPi to Debian) and I wanted to relaunch my Venv. I started by deleting the `.venv` folder I had (which was not that easy as some files were protected and this might have been my mistake). * Then ```pip install venv``` which worked perfectly. * And w...
I had my files transferred on another OS (from RetroPi to Debian) and I wanted to relaunch my Venv. I started by deleting the .venv folder I had (which was not that easy as some files were protected and this might have been my mistake). * Then
install venv
which worked perfectly. * And when I try to run
-sh
    (sudo) python3 -m venv .venv
it runs for a few seconds, doesn't give any message and doesn't create the .venv file or nothing. * Having sudo or not in the command doesn't change anything. * I tried changing permissions of the folder
-sh
    chmod 777 folder_name
but same result. The fact that I have no error message makes me unable to do precise research and I'm a newbie regarding Linux.
Daeltam (13 rep)
Jan 1, 2025, 11:25 AM • Last activity: Jan 7, 2025, 10:28 AM
Showing page 1 of 20 total questions