[Solved] How set up Python Environment variables in Rocky Linux

i have installed Rocky linux 5 or 6 days ago, just now i have installed VS codium and GCC,GDB & g++, i can code in C language without erros.
but python and java are not working.

i installed python and java using following commands.


sudo dnf install python -y && sudo dnf install java -y

Please help me out, i know how to set up envirnomental variables in windows, i am new to linux, i tried couple of articles and youtube videos, nothing seems to working for me.

thanks.

VS codium error:

python -u "/home/username/Music/code/test.py"
[username@device-name code]$ python -u "/home/username/Music/code/test.py"
bash: python: command not found...
<pre>[root@device-name ~]# python --version
bash: python: command not found...

[root@device-name ~]# python3 --version
Python 3.6.8

[root@device-name ~]# java --version
bash: java: command not found...

[root@device-name ~]# gcc --version &amp;&amp; gdb --version &amp;&amp; g++ --version
gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-4)
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

GNU gdb (GDB) Red Hat Enterprise Linux 8.2-16.el8
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later &lt;http://gnu.org/licenses/gpl.html&gt;
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

g++ (GCC) 8.5.0 20210514 (Red Hat 8.5.0-4)
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[root@device-name ~]# 

</pre>

try:

python3 -u "/home/username/Music/code/test.py"

if you are running that from Visual Code, then you need to configure Visual Code to use python3 instead of python (that would have been the name for python2 on older systems - python3 is not named python).

1 Like

How can I configure VS codium or code to use Python3.

Go into File → Preferences → Settings. Then search for python. Then it should show under Extensions, something like my screenshot below:

file:///home/ian/Pictures/vscode.png

1 Like

sir
i am using VS codium instead of Vs Code,

> Extensions i am using Code runner, i am installed python extension hoping it would work, still no luck and for some strange reason jupitor extesnion automatically installed.

**VS CODIUM VERSION**
Version: 1.62.3
Commit: ccbaa2d27e38e5afa3e5c21c1c7bef4657064247
Date: 2021-11-19T00:20:00.672Z
Electron: 13.5.2
Chrome: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Linux x64 4.18.0-348.2.1.el8_5.x86_64



Doesn’t it have anything like FilePreferencesSettings ?

1 Like

i posted screenshot showing python is not there.

Sorry, missed that.

Nevertheless, if Codium mimics Code, then why would it not have similar, configurable options?

What if you don’t filter with “python” … what Settings are there for User?

1 Like

The python option in the screenshot, has a cog wheel in the bottom right hand corner. Click it, chances are you can change the config there. Either that or search python in the workspace option instead of user option. I use official VS Code, rather than some other version of it, so was much easier to find the config options. You’ll have to search through it, if not, just use official VS Code instead.

1 Like

for java there 3 option for you

  1. if you going to use jdk 11 then use this
    sudo dnf install java-11-openjdk-devel
    by the way if you type dnf install java-11-openjdk- then double tab it will show you many option like the documentation if you want to install it also there demo and src code and other option pick what ever you want

  2. if you going to use jdk 17 the latest LTS version
    use this sudo dnf install java-17-openjdk-devel
    you can use the same trick in the previous option but with this dnf install java-17-openjdk- then double tab

  3. for jdk 8 use this dnf install java-1.8.0-openjdk

this installation will do the path for you so no need to do anything

and for an idea for java i would go for IntelliJ IDEA: The Capable & Ergonomic Java IDE by JetBrains there community version which is free
for easy way to install that ide and it keep updated use there toolbox JetBrains Toolbox App: Manage Your Tools with Ease it’s appimage app after you download it extract it then set the file to be executable right click on the file then properties then permission then check allow executing file as program then click on it and you good to go

hope that help and have a nice day :slight_smile:

2 Likes

@JustSomeone @iwalker @jlehtone thanks alot, its working now.
i had to re-install vs codium to work.

VS codium is a community-driven, freely-licensed binary distribution of Microsoft’s editor VS Code.

VS codium just basically VS code without tracking and some proprietary code removed.
give it a try.

1 Like

@Pulpy_orange you very welcome and happy coding :slight_smile:

1 Like

A good overview of issue, reasons, and solutions can be found at: What, no Python in Red Hat Enterprise Linux 8? | Red Hat Developer

But even the python3 version is quite old. For any serious python development (other than “system” related) it can be useful to create environments using something like miniconda and conda-forge for easy access to modern Python versions and the wealth of packages that go with it.

The base system tools, e.g. dnf, do use their own copy of python that is and always will be python 3.6.

The AppStream, however, does currently provide python 3.8 and 3.9. You can thus have 3.9 as the python that you see, rather than the 3.6. (Well, up to May 2024, when that stream goes EOL. By then there probably is something newer.)