Linux环境下安装运行PyPy3遇问题求助:依赖缺失与命令未找到
Hey there, let's work through your PyPy3 problems one by one:
1. Resolving the libbz2.so.1.0 shared library error
The error you're seeing means your Linux system is missing the bzip2 library that PyPy3 depends on. Different distros have different packages for this:
Debian/Ubuntu-based systems:
Run this command to install the required library:sudo apt update && sudo apt install libbz2-1.0CentOS/RHEL-based systems:
Use yum or dnf to install the bzip2 libraries package:sudo yum install bzip2-libs # Or for newer CentOS/RHEL versions: sudo dnf install bzip2-libs
Once the library is installed, try running the PyPy3 binary from your extracted directory again—it should work without the shared library error.
2. Making pypy3 globally accessible
Right now, your system doesn't recognize the pypy3 command because the binary's directory isn't in your system's PATH. You have a few options to fix this:
Option 1: Temporarily add to PATH (resets after reboot)
Run this command, replacing /path/to/your/pypy3-folder with the actual absolute path to your extracted PyPy3 directory (e.g., ~/Downloads/pypy3-v6.0.0-linux64):
export PATH=/path/to/your/pypy3-folder/bin:$PATH
After this, you can run pypy3 filename.py from any directory.
Option 2: Permanently add to PATH
Edit your shell's configuration file (like ~/.bashrc for bash or ~/.zshrc for zsh) and add this line at the end:
export PATH=/path/to/your/pypy3-folder/bin:$PATH
Save the file, then run source ~/.bashrc (or the appropriate file for your shell) to apply the changes immediately. This will persist across reboots.
Option 3: Create a symbolic link
If you prefer, you can link the PyPy3 binary to a directory that's already in your PATH (like /usr/local/bin):
sudo ln -s /path/to/your/pypy3-folder/bin/pypy3 /usr/local/bin/pypy3
Now you can use pypy3 directly from anywhere in your terminal.
After addressing both issues, you should be able to run PyPy3 smoothly on your Linux machine!
内容的提问来源于stack exchange,提问作者Doe a

