How do I enable python35 from Software Collections at login? - rhel7

I followed the Software Collections Quick Start and I now have Python 3.5 installed. How can I make it always enabled in my ~/.bashrc, so that I do not have to enable it manually with scl enable rh-python35 bash?

Use the scl_source feature.
Create a new file in /etc/profile.d/ to enable your collection automatically on start up:
$ cat /etc/profile.d/enablepython35.sh
#!/bin/bash
source scl_source enable python35
See How can I make a Red Hat Software Collection persist after a reboot/logout? for background and details.

This answer would be helpful to those who have limited auth access on the server.
I had a similar problem for python3.5 in HostGator's shared hosting. Python3.5 had to be enabled every single damn time after login. Here are my 10 steps for the resolution:
Enable the python through scl script python_enable_3.5 or scl enable rh-python35 bash.
Verify that it's enabled by executing python3.5 --version. This should give you your python version.
Execute which python3.5 to get its path. In my case, it was /opt/rh/rh-python35/root/usr/bin/python3.5. You can use this path to get the version again (just to verify that this path is working for you.)
Awesome, now please exit out of the current shell of scl.
Now, lets get the version again through this complete python3.5 path /opt/rh/rh-python35/root/usr/bin/python3.5 --version.
It won't give you the version but an error. In my case, it was
/opt/rh/rh-python35/root/usr/bin/python3.5: error while loading shared libraries: libpython3.5m.so.rh-python35-1.0: cannot open shared object file: No such file or directory
As mentioned in Tamas' answer, we gotta find that so file. locate doesn't work in shared hosting and you can't install that too.
Use the following command to find where that file is located:
find /opt/rh/rh-python35 -name "libpython3.5m.so.rh-python35-1.0"
Above command would print the complete path (second line) of the file once located. In my case, output was
find: `/opt/rh/rh-python35/root/root': Permission denied
/opt/rh/rh-python35/root/usr/lib64/libpython3.5m.so.rh-python35-1.0
Here is the complete command for the python3.5 to work in such shared hosting which would give the version,
LD_LIBRARY_PATH=/opt/rh/rh-python35/root/usr/lib64 /opt/rh/rh-python35/root/usr/bin/python3.5 --version
Finally, for shorthand, append the following alias in your ~/.bashrc
alias python351='LD_LIBRARY_PATH=/opt/rh/rh-python35/root/usr/lib64 /opt/rh/rh-python35/root/usr/bin/python3.5'
For verification, reload the .bashrc by source ~/.bashrc and execute python351 --version.
Well, there you go, now whenever you login again, you have got python351 to welcome you.
This is not just limited to python3.5, but can be helpful in case of other scl installed softwares.

Related

Installing Python modules

I am trying to install the pyperclip module for Python 3.6 on Windows (32 bit). I have looked at various documentations (Python documentation, pypi.python.org and online courses) and they all said the same thing.
1) Install and update pip
I downloaded get-pip.py from python.org and it ran immediately, so pip should be updated.
2) Use the command python -m pip install SomePackage
Okay here is where I'm having issues. Everywhere says to run this in the command line, or doesn't specify a place to run it.
I ran this in the command prompt: python -m pip install pyperclip. But I got the error message "'python' is not recognized as an internal or external command, operable program or batch file.
If I run it in Python 3.6, it says pip is an invalid syntax. Running it in IDLE gives me the same message.
I have no idea where else to run it. I have the pyperclip module in my python folder. It looks like a really simple problem, but I have been stuck on this for ages!
You need to add the location of the python.exe to your $PATH variable. This depends on your installation location. In my case it is C:\Anaconda3. The default is C:\Python as far as I know.
To edit your path variable you can do the following thing. Go to your Control Panel then search for system. You should see something like: "Edit the system environment variables". Click on this and then click on environment variables in the panel that opened. There you have a list of system variables. You should now look for the Path variable. Now click edit and add the Python path at the end. Make sure that you added a semicolon before adding the path to not mess with your previous configuration.

RStudio gives "Incorrect function" when setting git as Version control

When I create a new project and select to create a new Git repository, or when I try to change the version control system in project options I receive a RStudio error stating "Incorrect function" with a big X and no extra information.
The below link has a similar issue, but their solution of changing the path for git.exe has not helped (i have tried all three paths)
https://support.rstudio.com/hc/en-us/community/posts/200632528-Git-Error-Incorrect-Function
Some extra notes:
RStudio allows me to clone repository to set new working directory
Also git works in bash, so i feel this is an RStudio issue.
I encountered the same error. For me it also had to do with using a network path not a local directory for the project location (as for lewis1211).
Workaround: Map the network drive. E.g. Map your //server/share to some drive, say Z: (using map network drive, if you are using windows). If you set your project up under Z: then, it works.
If you have already chosen "git.exe" in RStudio --> Tools --> Global Options --> Git/SVN, then try to open Rstudio shell and type git init. In my case it showed "Permission denied", and after running as administrator the problem has gone.
This is only a partial answer if it fixes your problem: I reproduced this when trying to use a network path for a project location. When using a local directory no error occurs. Could indeed be an RStudio issue.
Run you R studio as Project administration.
This solves my issue.
SOLVED.
I had the same problem. The Git-RStudio-Connection fails but git is working perfectly in the CMD. When running the git init command in CMD it works and creates a .git folder. But running the git init command in the RStudio terminal fails with a message Warning: unable to access 'C:/Users/%username%/.gitconfig': Permission denied ... fatal: unknown error occured while reading the configuration files.
The Version Control Sytem (VCS) or git-Panel does not appear in RStudio and selecting it in the projects options leads to the same message Error: Unzulässige Function (eng. Error: Incorrect function).
A closer look into the .gitconfig file should give you a new solution approach hopefully without having administration rights. Comparing the installation on the integration worksation with a productive workstation shows, that on the Test-Machine an incomplete .gitconfig file is on C:/Users/%username%/.gitconfig and on the Productive-Machine a complete gitconfig file is on Z:/.gitconfig. By the way, Z is a mapped drive which is linking to the company's user-profile settings (see CMD > echo %HOMEDRIVE%).
According to this analysis there should be multiple possible solution approaches:
(1) delete the corrupt .gitconfig and hope the the system is correctly looking into your profiles directory
(2) complete the .gitconfig file that all necessary information are there. The message fatal: unknown error occured while reading the configuration files could actually be a hint, that the first message access... permission denied is false and the problem lies in the incomplete file.
(3) Be aware that there can be a confusion between ".gitconfig" as FILE and ".gitconfig" as FOLDER. Check this with changing directory with cd to folder and cat to show the file content. It will tell you that you cannot display a folder as file-content.
(4) Change the location of the config file with git config --file FullnameToGitconfig. e.g. git config --file %USERPROFILE%/.gitconfig or git config --file %USERPROFILE%/.gitconfig/gitconfig or git config --file %HOMEDRIVE%/.gitconfig etc.
[user]
name = DOE John
email = john.doe#acme.com
[merge]
tool = kdiff3
[mergetool "kdiff3"]
path = C:/Program Files/KDiff3/kdiff3.exe
[diff]
guitool = kdiff3
[difftool "kdiff3"]
path = C:/Program Files/KDiff3/kdiff3.exe
[core]
editor = \"C:/Program Files (x86)/GitExtensions/GitExtensions.exe\" fileeditor

Cannot implement git version control on R-Studio (Version Control System: NONE)

I'm trying to put a project under version control in R-Studio. I have installed git and everything is working from the git bash command-line. However, when I go to Tools >> Version Control in R-Studio, it says "None" under "Version Control System."
I have attached a screenshot here: http://i.imgur.com/Arc12GG.png
Does anybody know how to fix this?
Even after setting the path to the git executable on my Mac at "Macintosh HD/usr/bin", RStudio still showed "None" for the version control option. In Terminal, I entered "config git" and was greeted by the message that I had to agree to the new Xcode/iOS license. I was able to do that in Terminal by typing "sudo xcodebuild", entering my admin password, then scrolling to the end of the agreement text and entering "agree". Then git showed up as an option for version control. I mention this in case others are stymied even after setting the path to the git executable.
For Windows 10 users, even if you had git lovingly installed at:
C:/Program Files (x86)/Git/bin/git.exe
At some stage the update install moves it into your AppData directory. Thanks Redmond. (I think around Git 2.6.4)
TO FIX:
Make sure like #arvi1000 says above "Did you specify the path to the git executable in Global Options (not project options)? " - set path first in Global options in Rstudio under Tools
Change path under Git/SVN the Git Executable path from Program files to new location of git.exe now in Appdata. e.g. for my userprofile Info:
C:\Users[Your user profile "Info"]\AppData\Local\Programs\Git\bin
Now look in RStudio Project Options under Git/SVN to set Version Control System.
MORE HELP
See these answers in this thread for more and if you cannot find git.exe this is a helpful search tip.

Preserve files/directories for rpm upgrade in .spec file(rpmbuild)

I wrote a .spec file on RHEL and I am building RPM using rpmbuild. I need ideas on how to handle the situation below.
My RPM creates an empty logs directory when it installs first time within the installation folder like below
/opt/MyInstallation-1.0.0-1/some executables
/opt/MyInstallation-1.0.0-1/lib/carries shared objects(.so files)
/opt/MyInstallation-1.0.0-1/config/carries some XML and custom configuration files(.xml, etc)
/opt/MyInstallation-1.0.0-1/log--->This is where application writes logs
When my RPM upgrades MyInstallation-1.0.0-1, to MyInstallation-1.0.0-2 for example, I get everything right as I wanted.
But, my question is how to preserve log files written in MyInstallation-1.0.0-1? Or to precisely copy the log directory to MyInstallation-1.0.0-2.
I believe if you tag the directory as %config, it is expected that the user will have files in there, so it will leave it alone.
I found a solution or workaround to this by hit and trial method :)
I am using rpmbuild version 4.8.0 on RHEL 6.3 x86_64. I believe it will work on other distros as well.
If you install with one name only like "MyInstallation" rather than "MyInstallation-version number-RPM Build Number" and create "logs directory as a standard directory(no additional flags on it)[See Original Question for scenario] Whenever you upgrade, you normally don't touch logs directory. RPM will leave its contents as it is. All you have to do is to ensure that you keep the line below in the install section.
%install
install --directory $RPM_BUILD_ROOT%{_prefix}/%{name}/log
Here, prefix and name are macros. That has to do nothing with underlying concept.
Regarding config files, the following is a very precise table that will help you guarding your config files. Again, this rule can't be applied on logs our applications create.
http://www-uxsup.csx.cam.ac.uk/~jw35/docs/rpm_config.html
Thanks & Regards.

How to build binaries and use it in several machines in Unix?

I have source code of a compiler which I am building like this:
/path/to/srcdir/configure --prefix=/path/to/installdir
make
make install
I want to distribute the resulting 'installdir' to other machines, with the intent that anybody could use the compiler binaries without going through the 3-stage build process (I am just including the installdir in my distribution tarball).
For testing, I am copying the installdir to another machine under a different user, and then just trying to compile a test program using the binaries I just copied over, like this:
installdir/bin/ucc -mp -o test load_bl.c
Then, I get an error as follows:
cc1: error: /home/sghosh/normalbuild/installdir/open64-gcc-4.2.0/include: Permission denied
cc1: error: /home/sghosh/normalbuild/installdir/open64-gcc-4.2.0/lib/gcc/x86_64-redhat-linux/4.2.0/include: Permission denied
cc1: error: /home/sghosh/normalbuild/installdir/open64-gcc-4.2.0/x86_64-redhat-linux/include: Permission denied
The /home/sghosh/normalbuild/install is what is specified as --prefix during configure on my build machine. The installdir/bin/ucc binary require some files in the open64-gcc-4.2.0 dir under installdir, but since that is the path mentioned in --prefix, so it's still looking for it there, and I want it to look into the same dir in the current machine. FYI, I do not have sudo/root privileges.
How do I come up with a binary distribution that would work in any machine (build once, use anywhere sorts), and not look into the initial --prefix path in this case?
I have had a similar question in superuser, but since lots of edit happened and I got no response to the new question, so I am writing it here.
Check this tool: https://github.com/pgbovine/CDE
CDE is a tool that automatically packages up the Code, Data, and Environment involved in running any set of Linux commands so that they can execute identically on another computer without any installation or configuration.

Resources