I want to know how to add a python3.7 path for non root unix user on EC2.
I created an EC2 instance and logged in via ssh. And I created a user called jpx by adduser jpx. So my home directory has ec2-user and jpx sub directories.
As a root user, I installed python3.7, following this tutorial. Basically, I followed these steps:
yum install gcc openssl-devel bzip2-devel libffi-devel
cd /opt
sudo wget https://www.python.org/ftp/python/3.7.9/Python-3.7.9.tgz
sudo tar xzf Python-3.7.9.tgz
cd Python-3.7.9
sudo ./configure --enable-optimizations
sudo make altinstall
sudo rm /usr/src/Python-3.7.9.tgz
As a result, my python3.7 was installed at /usr/local/bin/python3.7.
Questions:
As a root user, I was able to add /usr/local/bin/ to my PATH in the bash_profile. So now the command python3.7 works. But I want to set the command python3 instead of python3.7, so that I can run python3 app.py instead of python3.7 app.py. How can I do this?
As a user jpx, I cannot run the command python3.7. It returns bash: python3.7: command not found. When I print echo $PATH, indeed its' /sbin:/bin:/usr/sbin:/usr/bin and the python3.7 path is not included. As a linux beginner I want to understand why this happens. And what is the solution? Not only python3, but also I need to install pip.
Thank you for your help!
You can link the executable file
cd /usr/local/bin
ln -s python3.7 python3
Add the path to the user home .bashrc
vi /home/jpx/.bashrc
Add the following line
export PATH="/usr/local/bin:$PATH"
Logout and login again
Related
Whenever I try to install packages through homebrew or pip, it gives me a permission error. (I'm using macOS Catalina)
I somewhat got pip to work by using the "sudo -H" prefix. It downloads them successfully but then when I attempt to import them in Python, it tells me the module wasn't found. Earlier today I changed the default version of Python to 3.8.2, but the same error was happening way before that.
Here's the Homebrew command I used:
brew install libyaml
Here's what it's returning:
Error: Permission denied # apply2files - /usr/local/lib/node_modules/json-server/node_modules/term-size/vendor/macos/.DS_Store
you need to check user permissions on the first /usr, /usr/local, and /usr/local/lib directories. you need rwx permissions to write content in these folder. Failing this permission on any folder will not allow you to modify content in /usr/local/lib.
you can use sudo chmod u+rwx folder_name to provide read write execute on the folders. If you want to providerwx permission to all folder inside /usr use sudo chmod u+rwx -R /usr
I'm trying to provision a Vagrant machine to run liquibase. I'm able to install java, get liquibase through wget but I'm having trouble adding the liquibase executable to PATH. My current provisioning script looks like the following:
apt-get update
apt-get install -y unzip
apt-get install -y openjdk-8-jre-headless
mkdir liquibase
cd liquibase
wget https://github.com/liquibase/liquibase/releases/download/v3.8.5/liquibase-3.8.5.tar.gz
tar -zxvf liquibase-3.8.5.tar.gz
rm liquibase-3.8.5.tar.gz
export PATH=$PATH:/home/vagrant/liquibase
source ~/.profile
source ~/.bashrc
If I run export PATH=$PATH:/home/vagrant/liquibase inside the machine it works. But during provision it doesn't work. I ssh into the machine and it's not in the PATH. I added the last two lines to see if I could make it persistent by adding it to .profile and .bashrc but it's still not working.
Any idea on how to solve this issue?
New PATH is not avaliable in your interacive shells.
Include your new PATH into the .bashrc file to have it avaliable when you login the machine.
echo 'export PATH="${PATH}:/home/vagrant/liquibase"' >> /home/vagrant/.bashrc
source /home/vagrant/.bashrc
I installed python 3.6 before and installed python 3.7.4 today. When I type python3 in command, it opens python 3.6, I want to change it to python 3.7.4.
which python3 shows /Library/Frameworks/Python.framework/Versions/3.6/bin/python3,
but the link in /usr/local/bin/ is :
python3 -> ../../../Library/Frameworks/Python.framework/Versions/3.7/bin/python3
so is the case of pip3. why? ?
How can I change which python3 to python 3.7.4? I don't want to use alias.
I use MacOS 10.14.2
Your OS uses the PATH environment variable to look for the commands you write into the shell, so if you type python3 it will go through the directories listed in this PATH and check if there's your programm. It takes the first matching program and executes it, so in your case the directory /Library/Frameworks/.../3.6/bin is before the directory usr/local/bin, which means that the python3 from /Library/Frameworks/.../3.6/bin will be used.
You need therefore to change this PATH variable:
export PATH="/Users/sky/Documents/software/Montage-master/bin:/usr/share/file/magic/mercurial:/Library/Frameworks/Python.framework/Versions/3.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/mysql/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin"
You can put that into your ~/.bash_profile so that it is permanent, and you don't need to set it every time you open a new terminal window.
Note that this will not automatically update your path for the remainder of the session. To do this, you should run:
source ~/.bash_profile
Are you sure have python3.7 intalled?
you can view the folder
cd /usr/bin
Next you search the python's file:
find /usr/bin/ python3
if donĀ“t exist filename python3.7 install
sudo apt install python3.7
sudo apt update
I was trying to install the postgres through terminal on mac os. I used homebrew to install the postgres.
During the install I got following error
"Error: The brew link step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink share/man/man3/SPI_connect.3"
I also got error regarding initdb
"initdb: file "/usr/local/share/postgresql/postgres.bki" does not exist
This might mean you have a corrupted installation or identified
the wrong directory with the invocation option -L.
Warning: The post-install step did not complete successfully
You can try again using brew postinstall postgresql"
After the install I am not able to run any of postgres commands. I would really appreciate any help as I am new to postgres. Please, provide little explanation.
Thank You!
Not sure if this solution is the best, but so far this is the only one.
Note: I did this on a macOS environment
I have chowned the directory I wasn't allowed to write. (chown -R user/usr/local/lib/pkgconfig)
/usr/local/lib/pkgconfig` (assumed that dir should be mine anyway - since it's within /usr/local)
I ran
brew link postgres - so the links required are there
Then initdb /usr/local/var/postgres -E utf8 worked perfectly.
Running brew postinstall postgres --debug gives:
Errno::EACCES: Permission denied # dir_s_mkdir - /usr/local/var/postgres
Creating the directory manually and setting the right group worked:
cd /usr/local/var
sudo mkdir postgres
sudo chown <user> postgres
sudo chgrp admin postgres/
I'm working on the front end for a web app, but I'm trying to learn as much of the backend setup as I can as well. I am setting up redis on a new computer myself, but running into a few hiccups.
The wget command cannot be found, so I assume it Linux only? I am following these instructions to install redis on Mac OS 10.7. I have redis 2.0.0 installed, but while attempting to install 2.4.4 using the same commands, I am told redis-server, redis-cli, redis-benchmark cannot be found, and I can't copy them to /usr/local/bin.
I could not find an update command to bring redis up to the most recent version. I don't think it should be this difficult to install the most recent version on redis on Mac OS, but I can't see what I am doing wrong.
So far as I know, typing:
$ brew upgrade redis
should work, where $ indicates your command line. If it complains about HomeBrew not being installed, you can obtain that here. Brew is an excellent package manager, and a great way of taking care of your files.
If you're not using brew, then these steps will help you get up to date.
First, find the location of your installed redis-server instance before updating. In my case, it was in /usr/local/bin/, but it might also be in /usr/bin/. If it's not here, you can type which redis-server to find the location.
Next, download the redis tar file from https://redis.io/download, then install it from the directory it downloaded to:
cd Downloads
tar xzf redis-X.Y.Z.tar.gz
cd redis-X.Y.Z
make test
make
Next, we'll move the new installed redis to the location where the current instance is running:
sudo mv src/redis-server /usr/local/bin
sudo mv src/redis-cli /usr/local/bin
Now you should be ready to use redis-server and redis-cli in the new version.
PS - I also moved the redis-benchmark, redis-sentinel, redis-check-aof, and redis-check-dump files because they were also already in /usr/local/bin.
Ref: http://jasdeep.ca/2012/05/installing-redis-on-mac-os-x/
It would be better to follow this way.
$ brew update
$brew upgrade redis
Create a bash file...
cd ~
nano .update_redis
Go into the tmp directory and download the latest stable version
cd /tmp
wget http://download.redis.io/redis-stable.tar.gz
Decompress the files
tar xvzf redis-stable.tar.gz
Compile
cd redis-stable
make
Copy the bin programs
cp src/redis-cli /usr/bin/
cp src/redis-server /usr/bin/
cp src/redis-benchmark /usr/bin/
Set Permissions
chmod 755 /usr/bin/redis-cli
chmod 755 /usr/bin/redis-server
chmod 755 /usr/bin/redis-benchmark
Execute
bash .update_redis