Installation problems of PyPy and virtualenv

Source: Internet
Author: User
Tags mail exchange virtual environment virtualenv

Installation problems of PyPy and virtualenv

Description: This blog is written by Bitpeach original, do not commercial. Reprint free, please indicate the source, thank you.

(0) Background

Virtualenv the details of the tool is what, please self-Baidu. Here is a general introduction, mainly to achieve different versions or different environments of Python execution does not produce interference with each other. A bit like a Python virtual machine, can be so superficial understanding. For example, sometimes you need python2.x, and sometimes you need to python3.x. Install two different versions on a single host at the same time. First, these two different versions of Python need to install a third-party library, which may cause interference. Second, when these two versions of Python start or look for the import library, it is possible that the path or system environment variables of the two versions of Python are improperly set, resulting in a failure to run successfully. Therefore, it is recommended to use virtualenv, so that different virtual worlds will not cause interference. PyPy is another version of Python, which in fact does not belong to any version. It is equivalent to Python's genetic mutation, which realizes the alienation of the Python gene and produces the Python "mutant" world. Although Python has been very efficient, the design of Cython has changed, but the pypy that turned out to be fundamentally and powerfully changed the efficiency of Python, because PyPy is, in a way, Python itself. I need to install pypy, but I'm worried about conflict with python2.7, so I use Virtualenv to specify a virtual environment. Therefore, a number of problems arose. But the problem is the cause of progress, the problem is the impetus to change the status quo, the problem has brought many unexpected things.

(a) demand

These things related to my research are very time-consuming, I can only produce a few percent of the work a day, because my research is more cumbersome, need to constantly statistical data, and constantly verify the data, and constantly evaluate the data. Using Python is the first choice for debugging and compiling, making it easy to change and retrofit. However I need to use pypy to speed up my program, first of all because I write a program that is too bad to optimize Python code. Second, the Python multithreading problem is not resolved. So I have written a simple discussion of Python multithreading, and interested people can see the blog "Python multi-Threading problem data lookup and summary by Tsy". As the Gil problem bothered Python, I found that sometimes Python multithreaded execution was less than a single thread when I was actually doing it. The key issue or failed to unlock the Gil, there are users can do the program to unlock, but I feel a little hard and difficult. So I decided to use Cython or Pypy,cython may write a special article during the winter vacation.

The use of virtualenv for PyPy designated method, the first is to learn The5fire Netizen, its blog "Create virtualenv virtual environment based on PyPy" very valuable reference. Thefivefire's main attempt is on Linux, so it's a little different from me. My environment is windows8,python2.7.3,virtualenv1.11.x-win32.exe. After interacting with several of the messages, Thefivefire is right, PyPy is less deployed on Windows, pypy third-party libraries support less. So I directly found PyPy homepage [http://pypy.org/], find the main station management team contact, with the mail exchange. The number of maintenance teams is still very great, and the name of the maintainer can be found on the website [Https://bitbucket.org/pypy/pypy/src/tip/LICENSE].

(b) E-mail exchange

The first message asked a question, Windows virtualenv for PyPy to specify the default interpreter (this action please Baidu), you need to use the directive <virtualenv-p>, otherwise the default designation is System version python. Obviously if you use pypy acceleration, of course you can't choose the system version. It is therefore necessary to use the VIRTUALENV directive, specifying PYPY as the default interpreter, but error after the input is complete.

The main issues are:

(1) I want to instal pypy but does not confuse the the 3rd packages or libraries with Python2.7 already in my operate SYS TEM Windows 7/8 (32bit). Then I choose to Follow the tutorial settings to install virtualenv just like "Installing using Virtuale NV ".

(2) After I install virtualenv successfully, I need-arrange a new space for pypy so that I download the PyPy availab Le to Windows as Python2.7 compatible pypy 2.4.0-windows binary (32bit) shown. (3) then I extract the Pypy-2.4.0-win32.zip file to normal foleder and use virutalenv commands like ">virtualenv.exe -P \pathto\pypy.exe ". This command "-P $PATH" means I need to choose PyPy as a default Python interpreter,otherwise it'll choose Python27 alre Ady installed in my Windows system. However the command comes a error and fail to build a virtual environment for PyPy. From "On" , I truly realized the specific parameters in the "command in Windows and Unix/linux" is different. Although I notice that your tutorial shows that $ virtualenv-p/opt/pypy-c-jit-41718-3fb486695f20-linux/bin/pypy my-p Ypy-env with a difference between WINDOWS7/8 and Unix/linux, I-still can not solve the problem in Windows 7/8 and do Not know how to build a virtual environment with appointing PyPy to a default interpreting Python environment in Windows 7 /8.

The team members reply to the following:

The latest released virtualenv is version 1.11.6 which does does support PyPy 2.4.0 and earlier on Windows. A Fix was merged to Virtualenv after the This version (released) so any newer release would be fixed. In the mean time can:
1. Run "virtualenv-p path\to\pypy.exe New_path" and it would fail
2. Copy by hand the directories Lib_pypy and Lib-python from path\to to New_path
3. Rerun Virtualenv, it should complete cleanly after installing Setuptools and Pip

The reply clearly pointed out that there is no virtualenv to support the latest pypy, but he offers a way to try. I follow its actions, or fail. I later thought that such an operation was the best way to solve the problem and that the reason for the unsuccessful is that it boils down to the functionality of the Virtualenv tool that is not powerful enough. So I queried Virtualenv's instructions. Virtualenv has been updated to 12.0.5 (2015-01-03) at the time of this blog post and has roughly experienced a 0.8.x to 1.11.x update in its version update history for dozens of times. At the time of the error, it was the December 2014 experiment. At that time I used the 1.11.x version, the following version 1.5 is written to start supporting PyPy, but I queried the material, should refer to PyPy. 1.7.2 can begin operations on Windows systems using VIRTUALENV for PyPy functionality. Version 1.10 You can specify the default interpreter.

1.5~~~* ADD support for PyPy.
1.10 (2013-07-23) ~~~~~~~~~~~~~~~~~* Added support for pypy3k* Added the option to use a version number with the '-P ' opt Ion to get the  system copy of this Python version (Windows only)

According to the citations in the previous release notes, Virtualenv supports PyPy, and specifies PyPy as the default interpreter, or not. Version 1.10 only says that you can specify the default interpreter, but not that you can specify Pypy.exe. So I mistakenly thought that the 1.11.x version can also be done. So I was only dead horse when live horse medicine, so follow the above mail reply, the PyPy Lib library copy in the virtual environment, but failed to start, at that time in mid-December, I will be wrong summary and issued a second email as follows. (Please note that the following method is problematic, so I summarize the error and ask for help again.) )

With your help, I has some new questions as follows.

    (1) I Check the virtualenv version list and the 1.11.6 are the latest by this URL. There is no newer version than. It means that 1.11.6 version is the newest and no versions can support pypy-2.4.0.       (2) Then I keep the complete file of Pypy-2.4.0 as an old path and  build a new file to copy the directories Lib_pypy and Lib -python into the new file.       (3) and I Use the command "Virtualenv  -p  \path\to\ol dfile\pypy.exe  \path\to\newfile ". As the pictures below, please allow me to explain them.          [3-1 ] I already install python2.7 and virtualenv 1.11.6.          [3-2] I put a comple Te pypy-2.4.0 programs in File "E:\Python27\Scripts\pypy-2.4.0-win32" as a old path. The picture below presents this. (3-2 picture)           [3-3] I build a new file named "VirtualEnvpypy "and copy the Directories Lib_pypy & Lib-python from File" Pypy-2.4.0-win32 "to new File" Virtualenvpypy ". The picture below presents this. (3-3)           [3-4] Finally, I use the command as below. The Pictures below present this. In (3-4 picture B), the red one was old path and the blue one new path. If My command is a wrong, you can help me to revise it. (3-4 picture A) (3-4 picture B)

(4) The command is failed. And I guess the intention to appointing Pypy.exe as a default interpret could be isn't available to the Windows 7/8 versions a nd Pypy-2.4.0. I still worry a truth that a lot of the materials in foreign or domestic forums is about pypy-2.4.0 with virtualenv in Linux such as CentOs. I really doubt my idea of the installing pypy-2.4.0 in virtualenv with the Windows 7/8 is correct. All pictures is uploaded as attachments.

The version 1.11.x is not enough, so this email has not been answered. Until... This evening Armin Rigo replies and reminds the latest virtualenv has been released.

I see that the current virtualenv version was now 12.0.5 (https://pypi.python.org/pypi/virtualenv/#downloads).  I assume that this means so the fixes Matti talks about is now officially part of it. Can you try again with this version 12.0.5?

One view indeed, released a new version of Virtualenv, and then try again, found that can be used, successfully set up a virtual environment, and developed a pypy as the default interpreter, is an illustration, the relevant virtualenv instructions to use, you can search the relevant blog or Baidu Library, Alternatively, please click here to download the virtualenv instruction document. It is commendable that Virtualenv released the new tool very quickly, and that the version number went straight from 1.11.6 to 12.0 and then to the present (2015-1-7) of 12.0.5. It seems that there are some important changes to the version content. Worthy of further exploration.

(iii) Summary thinking

Summary experience: If you use Virtualenv to specify pypy2.4.0 as the default under Windows, the VIRTUALENV version is required in 12.0.5. is not 12.0.x above need to self-verify, because I only experimented with version 12.0.5. The above article is actually to verify this sentence: The whole process shows that the latest pypy2.4.0 and 1.11.x version of virtualenv in Windows is not border, at least the need to use the 12.0.5 version.

So also verified a sentence, the essence of science and technology lies in constant exploration, verification, that is toss. PyPy acceleration and Cython, the overall view is very good. At present pypy is not very mature, many third-party libraries have not been supported, so the homepage launched a donation activity, the donation project has a scientific calculation package, There are pypy versions that support python3.x, as well as STM (this is the key product that removes the Gil, perhaps a single-core acceleration, a multithreaded real implementation). According to the Fund project, overall, the preparation of a large number, expenditure, time if planning, guess the end of 2015, the basic science calculation package, such as numpy,scipy, support PyPy version will be released. Borrow The5fire Netizen words, life is short, still use Python bar.

  

Installation problems of PyPy and virtualenv

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.