--When I try to install pypy with pyenv, I get a 403 error --Updated pyenv solved this problem --But pypy3.6-7.3.1 couldn't be installed (I ran into an unresolved issue) --On the other hand, I was able to install pypy3.6-7.3.0 --Bonus: When I calculated the circumference ratio with pypy, it worked about 4.7 times faster than CPython (only a simple experiment was conducted).
When I tried to install pypy3.6-7.3.1 with pyenv, an error message was displayed and the installation failed.
% pyenv install -v pypy3.6-7.3.1
/var/folders/fv/495qgk712lg73r5dxmr83mhh0000gn/T/python-build.20200822165404.41441 ~/work
Downloading pypy3.6-v7.3.1-osx64.tar.bz2...
-> https://bitbucket.org/pypy/pypy/downloads/pypy3.6-v7.3.1-osx64.tar.bz2
curl: (22) The requested URL returned error: 403
error: failed to download pypy3.6-v7.3.1-osx64.tar.bz2
BUILD FAILED (OS X 10.15.6 using 0000000000)
A 403 error is returned from the URL of the archive file for macOS referenced by pyenv.
Downloading pypy3.6-v7.3.1-osx64.tar.bz2...
-> https://bitbucket.org/pypy/pypy/downloads/pypy3.6-v7.3.1-osx64.tar.bz2
curl: (22) The requested URL returned error: 403
This is because Bitbucket no longer supports Mercurial, the contents of the repository are no longer accessible after July 8, 2020. ..
You can use the latest source code of pyenv. That's because the issue was fixed two days before the writing of this article (August 20, 2020). See pull request below:
--Wait for the updated release of pyenv --Or, install pyenv directly from GitHub
Here, we will explain the procedure to delete pyenv installed by brew and change to the direct installation method from GitHub.
First, make sure that the root directory of pyenv is in ~ / .pyenv
. (The following procedure assumes that the root directory exists in this path.)
% pyenv root
/Users/snjot/.pyenv
Remove pyenv from your system with brew uninstall.
% brew uninstall pyenv
Uninstalling /usr/local/Cellar/pyenv/1.2.20... (708 files, 2.5MB)
After that, follow the procedure described in Basic GitHub Checkout.
However, since the ~ / .pyenv
directory created by the brew version of pyenv remains, git clone cannot be performed according to the procedure as it is. Therefore, add some ideas to the procedure "1. Check out pyenv where you want it installed." You can do the following:
--Part 1. Porting the .git
directory
% git clone https://github.com/pyenv/pyenv.git ~/.pyenv-temp
Cloning into '/Users/snjot/.pyenv-temp'...
remote: Enumerating objects: 123, done.
remote: Counting objects: 100% (123/123), done.
remote: Compressing objects: 100% (121/121), done.
remote: Total 18256 (delta 106), reused 5 (delta 0), pack-reused 18133
Receiving objects: 100% (18256/18256), 3.65 MiB | 2.80 MiB/s, done.
Resolving deltas: 100% (12440/12440), done.
% mv ~/.pyenv-temp/.git ~/.pyenv/.git
% rm -rf ~/.pyenv-temp
--Part 2. File restoration from .git
% cd ~/.pyenv
% git reset HEAD --hard
HEAD is now at dc4e24e6 Fix PyPy download links (#1682)
See Official Procedures for the rest.
Finally, it's a good idea to make sure you've installed it correctly.
% pyenv --version
pyenv 1.2.20-2-gdc4e24e6
Update the version of pyenv and use the one after dc4e24e.
You can update it according to the Official Procedure. For reference, I've posted the command below:
cd $(pyenv root)
git pull
After implementing the solution, I ran into the following error while trying to install pypy3.6-7.3.1:
% pyenv install pypy3.6-7.3.1
Downloading pypy3.6-v7.3.1-osx64.tar.bz2...
-> https://downloads.python.org/pypy/pypy3.6-v7.3.1-osx64.tar.bz2
Installing pypy3.6-v7.3.1-osx64...
/Users/snjot/.pyenv/plugins/python-build/bin/python-build: line 1590: 44564 Abort trap: 6 "$PYTHON_BIN" -c "import $1" > /dev/null 2>&1
WARNING: The Python bz2 extension was not compiled. Missing the bzip2 lib?
/Users/snjot/.pyenv/plugins/python-build/bin/python-build: line 1590: 44565 Abort trap: 6 "$PYTHON_BIN" -c "import $1" > /dev/null 2>&1
WARNING: The Python readline extension was not compiled. Missing the GNU readline lib?
/Users/snjot/.pyenv/plugins/python-build/bin/python-build: line 1599: 44566 Abort trap: 6 "$PYTHON_BIN" -c "import $1" > /dev/null 2>&1
ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?
Please consult to the Wiki page to fix the problem.
https://github.com/pyenv/pyenv/wiki/Common-build-problems
After investigating, I came up with an unresolved issue and abandoned the installation of pypy3.6-7.3.1.
The previous version, pypy3.6-7.3.0, was successfully installed.
% pyenv install pypy3.6-7.3.0
Downloading pypy3.6-v7.3.0-osx64.tar.bz2...
-> https://downloads.python.org/pypy/pypy3.6-v7.3.0-osx64.tar.bz2
Installing pypy3.6-v7.3.0-osx64...
Installed pypy3.6-v7.3.0-osx64 to /Users/snjot/.pyenv/versions/pypy3.6-7.3.0
First, I checked the following URL according to the instructions output on the screen:
Please consult to the Wiki page to fix the problem. https://github.com/pyenv/pyenv/wiki/Common-build-problems
Then, it was confirmed whether the Prerequisites were satisfied. In my case, it met the Prerequisites.
Next, I tried all the solutions described in URL above. However, the problem was not solved.
I installed pypy3.6-7.3.0 with the following command to check if it was a special problem with pypy3.6-7.3.1, and it was installed without any problem.
% pyenv install pypy3.6-7.3.0
Downloading pypy3.6-v7.3.0-osx64.tar.bz2...
-> https://downloads.python.org/pypy/pypy3.6-v7.3.0-osx64.tar.bz2
Installing pypy3.6-v7.3.0-osx64...
Installed pypy3.6-v7.3.0-osx64 to /Users/snjot/.pyenv/versions/pypy3.6-7.3.0
I checked pyenv's GitHub repository and searched for issues and found a similar issue:
I abandoned the installation of pypy3.6-v7.3.1 because it is an unresolved issue at the time of writing the article.
Hello, pypy!
I was able to install pypy3.6-7.3.0, so I tried it.
% pyenv shell pypy3.6-7.3.0
% python
Python 3.6.9 (1608da62bfc7, Dec 23 2019, 10:50:17)
[PyPy 7.3.0 with GCC 4.2.1 Compatible Apple LLVM 10.0.0 (clang-1000.11.45.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>>
It's working properly: thumbsup:
Since it's a big deal, I tried to feel the speed of pypy by approximate calculation of the circumference ratio by the Monte Carlo method. pypy ran 4.7 times faster. It's wonderful.
import math
import random
import time
from typing import List, Tuple
def generate_random_point2d() -> Tuple[float, float]:
return (random.random(), random.random())
def generate_multiple_random_points2d(num_samples: int) -> List[Tuple[float, float]]:
points = []
for _ in range(num_samples):
points.append(generate_random_point2d())
return points
def calculate_l2norm(point2d: Tuple[float, float]) -> float:
return math.sqrt(point2d[0] ** 2 + point2d[1] ** 2)
def count_points_within_quadrant(l2norms: List[float]) -> int:
num_points = 0
for l in l2norms:
if l <= 1:
num_points += 1
return num_points
def calculate_pi(num_samples: int) -> float:
points = generate_multiple_random_points2d(num_samples)
l2norms = [calculate_l2norm(p) for p in points]
num_points_within_quadrant = count_points_within_quadrant(l2norms)
pi = 4 * num_points_within_quadrant / num_samples
return pi
if __name__ == "__main__":
random.seed(0, version = 2)
tic = time.time()
pi = calculate_pi(10_000_000)
tac = time.time()
print(f"pi = {pi}; ({tac - tic} sec)")
The code is available on this GitHub repository.
First run with pypy:
% python -m pimonte
pi = 3.1413028; (1.8637058734893799 sec)
Then run the same code in CPython:
% python -m pimonte
pi = 3.1413028; (8.742990016937256 sec)
Comparing the time it took to calculate, pypy was able to calculate 4.69 times faster than CPython.
This is a simple experiment, so I will omit the discussion.
Everyone, please feel the speed of pypy. that's all!
Recommended Posts