How to completely restore pythonpath? - pythonpath

I've had a few problems configuring a Django app (Miro Community), which was installed into a virtualenv on my Centos 6.0 Apache server. So, I removed the virtualenv and wish to start again.
However my pythonpath still points to the python2.7.2 library that was held in the old virtualenv, so when I type $python I get:
-bash: /opt/virtual-env/mc/bin/python2.7: No such file or directory.
Rather than rebuilding the server from scratch, I would prefer to 'clean' the pythonpath and restore it back to its basic form.
Could someone please describe (or point me towards a tutorial) for cleaning out pythonpath and starting from scratch.
Currently typing $whereis python displays:
python: /usr/bin/python2.6 /usr/bin/python /usr/bin/python2.7 /usr/bin/python2.6-config /usr/lib/python2.6 /usr/lib64/python2.6 /usr/local/lib/python2.7 /usr/include/python2.6 /usr/share/man/man1/python.1.gz

Related

install_driver(mysql) failed: Can't locate DBD/mysql.pm

Question is not repeated, first read the problem which I am facing, then mark it if it is repeated, will be helpful if repeatation of my question helps me in solving my problem, As I have been through all the links and solutions mentioned on other similar questions and problems but no luck.
I am trying to setup redmine git on my ec2-aws-instance with help of below link
https://docs.bitnami.com/installer/how-to/configure-advanced-integration-git-redmine/
I am able to properly connect redmine projects with my git repositories but once I reach third step on above link I am facing issue as below
step :- 3 Configure Git Access Control
Below is the error when try to secure my git repository with redmine user credentials.
[Thu Feb 21 17:46:26.918619 2019] [perl:error] [pid 26820:tid
139790464616192] [client 127.0.0.1:50156] install_driver(mysql)
failed: Can't locate DBD/mysql.pm in #INC (#INC contains:
/opt/bitnami/git/lib/site_perl/5.16.3
/opt/bitnami/perl/lib/5.16.3/x86_64-linux-thread-multi
/opt/bitnami/perl/lib/5.16.3
/opt/bitnami/perl/lib/site_perl/5.16.3/x86_64-linux-thread-multi
/opt/bitnami/perl/lib/site_perl/5.16.3
/opt/bitnami/perl/lib/5.16.3/x86_64-linux-thread-multi
/opt/bitnami/perl/lib/site_perl/5.16.3/x86_64-linux-thread-multi
/bitnami/ruby23stack-linux-x64/output/perl/lib/site_perl/5.16.3/x86_64-linux-thread-multi
/bitnami/ruby23stack-linux-x64/output/perl/lib/site_perl/5.16.3
/bitnami/ruby23stack-linux-x64/output/perl/lib/5.16.3/x86_64-linux-thread-multi
/bitnami/ruby23stack-linux-x64/output/perl/lib/5.16.3 .
/opt/bitnami/apache2) at (eval 6) line 3.\nPerhaps the DBD::mysql perl
module hasn't been fully installed,\nor perhaps the capitalisation of
'mysql' isn't right.\nAvailable drivers: DBM, ExampleP, File, Gofer,
Proxy, Sponge.\n at
/opt/bitnami/perl/lib/site_perl/5.16.3/x86_64-linux-thread-multi/Apache/Redmine.pm
line 557.\n App 26921 stdout:
Without third step my repositories are public, any who knows the repo url can clone my repos or perform other operations on my git repos. So third step is for security purpose as per above document link and which is important for me.
Once I add below line into apache config as per documentation mentioned I am getting above error in my bitnami log when I try to clone a repository
<Location "/">
AuthType Basic
AuthName "Redmine git repositories"
Require valid-user
PerlAccessHandler Apache::Authn::Redmine::access_handler
PerlAuthenHandler Apache::Authn::Redmine::authen_handler
RedmineDSN "DBI:mysql:database=bitnami_redmine;host=localhost;mysql_socket=installdir/mysql/tmp/mysql.sock"
RedmineDbUser "REDMINE_DB_USERNAME"
RedmineDbPass "REDMINE_DB_PASSWORD"
RedmineGitSmartHttp yes
</Location>
When I run a following command to clone a repo, without third step on documentation, I am properly able to clone the repo, but with third step I am failing and getting above error in log and below error on command line.
bitnami#127.0.0.1:/tmp$ git clone http://git.domain.com/test2
Cloning into 'test2'...
fatal: unable to access 'http://git.domain.com/test2/': The requested URL returned error: 500
I have even tried installing below package but no luck
sudo apt-get install libdbd-mysql-perl
my os is
Ubuntu 16.04.5 LTS \n \l
In order for a Perl installation to talk to a MySQL database, it needs to use the DBD::mysql module. This module isn't part of the standard Perl installation and needs to be installed separately. When you install it using the CPAN command line tool (cpan DBD::mysql) or using apt-get (apt-get install libdbd-mysql-perl) it is installed in the library directories used by the system Perl (the one that is installed as part of your operating system). You can confirm that this has been installed correctly by running the following commands:
$ perldoc DBD::mysql
$ perl -MDBD::mysql -le'print $DBD::mysql::VERSION'
If DBD::mysql is installed correctly, the first command will show you the documentation for the module and the second will give the version number.
But, as I said, this is installed for use by the system Perl installation. It appears from the error message you're seeing that your Bitnami installation isn't using the system Perl. It is, instead, using a separate Perl installation which is installed in /opt/bitnami.
So you need to get DBD::mysql installed in the module library for this Perl installation. It's possible to ask cpan to install a module in a different directory, but I'd be wary about just installing stuff into Bitnami's directory tree. I strongly suspect that an installation step has been skipped far earlier in the process. If Bitnami needs to use MySQL from a Perl program and installs its own Perl distribution complete with its own module library, then it should either include DBD::mysql in its installation or provide clear instructions on how to install it.
My suggestion would be to carefully go over the installation instructions for Bitnami and see what they have to say about installing MySQL support. If that doesn't work, you should take this question to Bitnami's support channels.

"Fatal error: 'EXTERN.h' file not found" while installing Perl modules

While trying to install Perl modules like JSON::XS or YAML::XS, i receive the same error:
XS.xs:1:10: fatal error: 'EXTERN.h' file not found
I use MacBook, xCode is up to date, everything else that could help is up to date too.
Since OS X El Capitan, Apple introduced System Integrity Protection which restricts writing to /usr/lib /usr/bin and other sensitive directories (even to root or sudo user) that are used by the installation of Perl bundled with the Operating System. This can cause issues when it comes to installing new modules and also if trying to install XS modules ( those linked to external C libraries ).
For this reason you should not consider the default Perl installation as a working development environment, especially if you are installing custom modules.
Check out this thread on PM and others. I had since El-Capitan managed to solve this before by manually building from tarball and adding a few params or environment variables to set the paths believing that it would be best to retain use of the system Perl but this is not the way to go. This makes your environment difficult to build but also brittle and sensitive to OS updates that may either break things in many different ways.
The best practice seems to be starting with a Perl using brew install perl and work in this environment, remembering to setup your bash_profile as directed by the installer.
Also worth remembering to do a brew link perl. If you receive warnings about this clobbering what looks like system Perl libraries don't worry - these are likely modules that were installed by you over the top and it will cause you less trouble to link over these. If you have concerns, make a note of which module installs will be cleared and re-install them once your environment is configured ( ie your module installer approach is configured using cpanm or sticking with the old perl -MCPAN -e shell etc)
This new Perl setup from brew eliminates the need to continuing running sudo which adds another layer of things that can go wrong as environment variables don't follow through and permission conflicts arise etc.
Finally to simplify package/module installation I suggest doing a brew install cpanminus. If you had previously already installed this, you can ensure the paths etc are configured by doing a brew reinstall cpanminus
If you want to take it another step further then you can install perlbrew as well which will give you the ability to run multiple versions of Perl as your user and configure these with their own libs and modules which can be very useful particularly if aligning with your production environment for testing etc.
One problem you may face if moving from system Perl to this kind of approach is needing to deal with any hangovers from installing things with sudo. It wis worth taking a little time to get all this set up right though and your issues going forward will be greatly reduced and you won't be left with that nagging feeling that you don't want to change anything for fear of it all breaking.
I have also come across a Perl Blog Article that suggests a fix for XS issues with perlbrew on Mojave
This Gist described updating your cpan shell install root though this shouldn't be necessary unless your cpan is stuck in an old config after taking steps above.
I've also raised this as a new issue on PerlMonks
After reading https://developer.apple.com/documentation/xcode_release_notes/xcode_10_release_notes#3035624 and installing the Additional headers via
sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
I successfully compiled without the missing 'EXTERN.h' error
In order to follow the common advice I also tried with Perlbrew to install a dedicated development version of Perl. Especially with the advice in mind First, do not use the system Perl on MacOS. The installed version is for Apple, not for you (see the discussion here: https://www.perlmonks.org/?node_id=1224727).
Unfortunately, the following error occurred:
Test Summary Report
-------------------
porting/libperl.t (Wstat: 65280 Tests: 35 Failed: 0)
Non-zero exit status: 255
Parse errors: No plan found in TAP output
Files=2653, Tests=1217766, 708 wallclock secs (52.74 usr 9.40 sys + 395.38 cusr 49.90 csys = 507.42 CPU)
Result: FAIL
make: *** [test_harness] Error 1
##### Brew Failed #####
Therefore, I decided to install it the following way (and not following the advice due to the error).
Even after having the above mentioned macOS SDK headers already installed on Catalina (macOS 10.15.2) it didn't work for me. I faced the issue during the installation of the Perl module Mac-SystemDirectory-0.13. The following steps (by identifying the missing file in hope of having a more generic approach for more or less equivalent issues) did the trick:
Locate the header file (in this case EXTERN.h)
sudo find /Library -type f -name EXTERN.h
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE/EXTERN.h
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Perl/5.28/darwin-thread-multi-2level/CORE/EXTERN.h
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE/EXTERN.h
Ensure the installed Perl version (here 5.18) match the header file:
perl -v | grep version
This is perl 5, version 18, subversion 4 (v5.18.4) built for darwin-thread-multi-2level
Export the path for the C-Compiler (note MacOSX10.15.sdk for Catalina and Perl Version 5.18)
export CPATH=/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE
Invoke the Makefile.PL with perl
perl Makefile.PL
BTW — For anybody who's still struggling with this, my workaround was:
bash% module="Sub::Util" # For example
bash% cpanm --configure-args="INC=-I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE" "$module"
Please try this
CPATH=$(dirname $(find /usr/local/Cellar/ -name EXTERN.h)) cpan JSON::XS
For Big Sur and perl 5.30, EXTERN.h is at /Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/System/Library/Perl/5.30/darwin-thread-multi-2level/CORE
I'm trying to upgrade CPAN itself and got that error. But I have /usr/bin/cpan and I can't write there so I have to tweak it to write the updated version to /usr/local/bin/cpan.
No promises, but yum install perl-devel worked for me.
As #huyz has helpfully pointed out, if you hit this error on a Mac, you don't have this option, even though this is probably your issue, and you need to follow one of the above methods of getting a version of Perl that isn't missing important chunks, as per other answers.
But if, dear reader, you hit this error on a linux host, as I did, then this might be an option for you.
Building on what E Lisse suggested, you might also have luck looking in
/System/Volumes/Data/Library/Developer/CommandLineTools/SDKs/
For example:
CPATH=$(dirname $(find /System/Volumes/Data/Library/Developer/CommandLineTools/SDKs/ -name EXTERN.h)) cpan JSON::XS
You could also find where EXTERN.h is located and add that to your shell by default, e.g. in your .bashrc or .zshrc file:
export CPATH=/System/Volumes/Data/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE/

Install GreenPAK Designer RPM

I am attempting to install closed source software from Silego, GreenPAK Designer, on a machine running Fedora 19. The supported installation packages on Silego's Website only target Ubuntu and Debian. I downloaded the .deb package and used Alien to convert to an RPM. So far so good, but a dry run of yum install showed dependency errors, which I solved by installing the necessary packages with yum:
qt5-qbase
qt5-qbase-gui
qt5-qtdeclarative
qt5-qtlocation
qwt
Now, yum installed the above libraries in /usr/lib/ but the GreenPAK RPM defaults to /usr/local/bin as the output dir. I figured I could run
sudo yum localinstall --nodeps --noscripts greenpak-designer-x.x.x.rpm
and get a successful install but I received conflict errors relating to dirs such as '/', '/usr', '/usr/bin' etc. I worked around this issue with:
rpmrebuild -pe --notest-install --replacefiles --noscripts greenpak-designer.x.x.x.rpm
and removing the offending lines in the script. It allowed me to install rpm but the software is broken because of dependency issues (not surprisingly). From the system log:
Jan 4 16:06:49 pelican gnome-session[1729]: /usr/local/greenpak-designer/bin/GP5: error while loading shared libraries: libicui18n.so.52: cannot open shared object file: No such file or directory
The machine has a /usr/lib/libicui18n.so.50
One thing I did not try is rebuilding my shared object cache with ldconfig, which sometimes solves problems with missing .so links when building from source but I don't see how that would apply in this instance (I'm not trying to link object files to libraries, rather simply trying to drop binaries in default install locations, no?)
Of course, I contacted the vendor and begged for an RPM. The contact was helpful but informed me the software folks are on a well deserved break. I thought I'd continue puttering with this in the meantime while I have time.
Any ideas? It seems the solution to this problem would be helpful when trying to install almost any closed source software targeting Debian on a Fedora box.

Scilab, backdoor error, octave conflict

I installed scilab.6.0.0 and backdoor fromscilab website (which I could not find it from Application>Module maneger>atom>Technical). I moved the backdoor file my home and from scilab command line I installed it
-->atomsInstall('/home/user/BackDoor_0.2_5.5.bin.x86_64.linux.tar.gz')
Even though, it installed backdoor successfully, when I restart the scilab I got this error message with backdoor
Start Toolbox BackDoor
Load macros
atomsLoad: An error occurred while loading 'BackDoor-0.2':
lib: Old binary lib detected. Please recompile it for Scilab 6.
As I understand I need to update the library, but I don't know how?
Would sb tell me explicitly (because I am a newbie user of scilab) how can I get over the error?
at the and I try to connect octave and scilab and when I try to run a demo script at octave I get also this error
>> sci_sim_example
Scilab connection failed
FYI: I already installed sci_cosim package (after I downloaded the package, I write to octave prompt >>pkg install sci_cosim_0.1.3.tar.gz), and I load it before running the script.
How can I recompile the lib: Old binary lib detected
Thank you so much for your help in advance
Here's what worked for me.
Download Scilab 5.5.2 (link for Linux 64bit version)
Extract the .tar.gz file in your preferred system location to install it there. Generally, my preferred location to extract / install self-contained packages is inside /opt .
You can extract the .tar.gz file using your filebrowser's graphical facilities, or on the command line; if /opt is owned by root (which it usually is) you may need to change ownership after extraction. E.g. your installation might look something like this:
cd /opt
sudo wget http://www.scilab.org/download/5.5.2/scilab-5.5.2.bin.linux-x86_64.tar.gz
sudo tar -xvzf ./scilab-5.5.2.bin.linux-x86_64.tar.gz
sudo rm scilab-5.5.2.bin.linux-x86_64.tar.gz
sudo chown $USER ./scilab-5.5.2 -R
Launch scilab by typing
/opt/scilab-5.5.2/bin/scilab &
in your terminal.
Once scilab is launched, go to Applications->Module Manager ATOMS. In the new window that comes up, click on All modules -> BackDoor -> Install.
You should get a message saying "Installation done, please restart SciLab".
Exit Scilab, and launch it again from the terminal. If you see a message:
atomsLoad: An error occurred while loading 'BackDoor-0.2':
File "/opt/scilab-5.5.2/share/scilab/contrib/BackDoor/0.2/etc/backdoor.start" does not exist.
then type the following commands in your terminal to rename the affected files:
cd /opt/scilab-5.5.2/share/scilab/contrib/BackDoor/0.2/etc/
mv BackDoor.start backdoor.start
mv BackDoor.quit backdoor.quit
Restart SciLab again. Hopefully this time it will work and SciLab will inform you that BackDoor is listening for connections at a certain port.
PS. Also note that from the octave side of things, the -auto option is no longer accepted when you perform a pkg install. You will need to load the sockets and sci_cosim packages manually each time you want to use this.

Elastic Beanstalk stops at EbExtensionPostBuild

I am having a problem deploying an EB instance with a custom .ebextensions file. This is the relevant part in that file:
container_commands:
01_migrate:
command: 'python db_migrate.py'
02_npm_build:
command: 'npm install && npm run prod'
As you can see, these commands are for migrating my PostgreSQL database (via a Flask backend) and building my React .jsx files.
If I leave these commands out, the deployment completes perfectly well. However, once I put them in, looking at the eb-activity.log it stalls at this part forever (as far as I can tell):
[2017-04-10T02:39:24.106Z] INFO [3023] - [Application deployment app-613e-170409_223418#1/StartupStage0/EbExtensionPostBuild] : Starting activity...
I also get this message on the Health overview in the console (this is after 1 day):
Performing application deployment (running for 1 day).
I have also tried to deploy it without those container_commands, and then including it back after the successful initial deployment. Then I get the same error message as before in eb-activity.log, and I also get this message on the Health overview:
Incorrect application version "app-2a3d-170409_214923" (deployment 1). Expected version "app-2a3d-170409_214923" (deployment 1).
Which is very strange because those two versions referenced are the same versions. I don't know what this means!
I found a solution.
Remove all you container_commands from .ebextensions/
Go ssh to instance, kill process with.
sudo killall python
Then Deploy new version without container_commands.
And start debuging all your container_commands, one by one on ssh..
Have fun.