问题
So I installed python on my FreeBSD box with these commans:
#portsnap fetch
#portsnap extract
#portsnap update
#cd /usr/ports/lang/python32
#make install clean
Everything worked and I got no error messages. Installation went smoothly. However when I type python in shell, I get:
python: Command not found.
Help?
回答1:
You can search it:
find /usr/bin /bin/ /usr/local/bin -iname 'python*'
回答2:
I know it's an old post but it is still not completely answered.
Command in accepted answer from guettli will return something like this:
$ find /usr/bin /bin/ /usr/local/bin -iname 'python*'
/usr/local/bin/python2.7
/usr/local/bin/python2.7-config
/usr/local/bin/python3.6m-config
/usr/local/bin/python3.6
/usr/local/bin/python3.6-config
/usr/local/bin/python3.6m
This means that to enter python shell you need to type "python3.6".
To use just "python" you may create a symlink:
ln -s /usr/local/bin/python3.6 /usr/local/bin/python
If you do not have permissions to create symlink (or you just do not want to), you may also create alias by editing default shells dotfile for your user, e.g. ~/.tcshrc by adding following line:
echo 'alias python python3.6' >> ~/.tcshrc
Alias will not automatically work in your current session until you relog to shell or "reload" changes in .tcshrc:
source ~/.tcshrc
By editing dotfile, alias will become permanent.
To create just a temporary alias for current session, you may set alias directly in the shell:
alias python python3.6
Temporary alias will disappear once you log off but can be "unaliased" in current session:
unalias python
回答3:
What if you type the full path(/usr/local/bin/python)? You probably forgot to type "rehash". Your shell needs to re-build the cache of programs available in your PATH.
回答4:
Hmm, but .bashrc is wrong choice because problem remains .. see bash(1) manpage
When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc, if that file exists.
and ..
Do not read and execute the personal initialization file ~/.bashrc if the shell is interactive. This option is on by default if the shell is invoked as sh.
Better solution?
echo 'alias python=python2.7' >>~/.bash_profile
Update: Real solution according to FreeBSD Release Notes
pkg install lang/python
which python
/usr/local/bin/python
来源:https://stackoverflow.com/questions/8881663/installing-python-on-freebsd-8-1