embedv.php_VirtualEnv和python-embed

I have a Windows machine running many apps using Python 2. I want to add a new program I wrote using Python 3. To make sure I don't screw anything up, I wanted to use a Virtualenv with Python 3 embedded (Python 3 embed amd64).

So I extracted the embedded python 3 and tried running virualenv with the --python option enabled.

I tried running the virtualenv

python -m virtualenv --python E:\Projects\python3-embed\python.exe E:\Projects\Virtual\

And I got this error:

Running virtualenv with interpreter E:\Projects\python3-embed\python.exe

Using base prefix 'E:\\Projects\\python3-embed'

Traceback (most recent call last):

File "C:\Python27\lib\site-packages\virtualenv.py", line 2328, in

main()

File "C:\Python27\lib\site-packages\virtualenv.py", line 713, in main

symlink=options.symlink)

File "C:\Python27\lib\site-packages\virtualenv.py", line 925, in create_environment

site_packages=site_packages, clear=clear, symlink=symlink))

File "C:\Python27\lib\site-packages\virtualenv.py", line 1147, in install_python

writefile(site_filename_dst, SITE_PY)

File "C:\Python27\lib\site-packages\virtualenv.py", line 362, in writefile

with open(dest, 'wb') as f:

FileNotFoundError: [Errno 2] No such file or directory: 'E:\\Projects\\Virtual\\python36.zip\\site.py'

I am not entirely sure how can I fix this error. There is a site.pyd file in python36.zip but it seems that virtualenv can't use it.

解决方案

Sorry in advance

I knew this is not the answer you meant to ask for, but I tried hard that (our) way, and got this solution at last.

TL;DR

WinPython64-3.7.0.2Zero.exe(64 bit version, YOU want this)

WinPython32-3.7.0.2Zero.exe(32 bit version)

The Too Long version

What I tried

Yes, I downloaded the python-3.7.0-embed-amd64.zip from this page

Yes, I set it up according to instructions in this page

Yes, it worked as a python interpreter

D:\temp\test>python

Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] on win32

>>>

Yes, I installed the package virtualenv

D:\temp\test>virtualenv --version

16.0.0

Then, boom (where you asked)

D:\temp\test>virtualenv ENV

Using base prefix 'd:\\portable\\python-3.7.0-embed-amd64'

Traceback (most recent call last):

File "runpy.py", line 193, in _run_module_as_main

File "runpy.py", line 85, in _run_code

File "D:\portable\python-3.7.0-embed-amd64\Scripts\virtualenv.exe\__main__.py", line 9, in

File "D:\portable\python-3.7.0-embed-amd64\lib\site-packages\virtualenv.py", line 712, in main

symlink=options.symlink)

File "D:\portable\python-3.7.0-embed-amd64\lib\site-packages\virtualenv.py", line 927, in create_environment

site_packages=site_packages, clear=clear, symlink=symlink))

File "D:\portable\python-3.7.0-embed-amd64\lib\site-packages\virtualenv.py", line 1149, in install_python

writefile(site_filename_dst, SITE_PY)

File "D:\portable\python-3.7.0-embed-amd64\lib\site-packages\virtualenv.py", line 363, in writefile

with open(dest, 'wb') as f:

FileNotFoundError: [Errno 2] No such file or directory: 'D:\\temp\\test\\ENV\\python37.zip\\site.py'

Seems a problem with virtualenv, searched, got an open issue, and I don't like that long solution.

This is the end of virtualenv.

Then, I tried venv:

D:\temp\test>python -m venv venv

D:\portable\python-3.7.0-embed-amd64\python.exe: No module named venv

Yes, the "built-in module" was lost, and the document for Embedded Distribution doesn't even mention it, just something about Tcl/tk (...), pip and the Python documentation are not included.

This is the end of venv.

Well, start again from my original point

The purpose to choose Embedded Distribution is (just like SOMEBODY):

To make sure I don't screw anything up

this include "don't install anything into my unstable and oversized Windows"

but doesn't necessarily "must use the Official Embedded Distribution"

something portable and trusted is enough, yes Portable Python

but the main page says "Portable Python is not being developed anymore", and provide some choice

after some reading, I figured out, what I want is WinPython, the version with a Zero

ta-da ... That's it.

Something about Embedded Distribution (from official document)

The embedded distribution is a ZIP file containing a minimal Python environment. It is intended for acting as part of another application, rather than being directly accessed by end-users.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值