Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pip with embedded python

Tags:

python

pip

I installed embedded python from here, titled "Windows x86-64 embeddable zip file", but it does not have pip installed, it does not have site-packages either, when I try to do python get-pip.py it failed to run because this file has import pip in it. So how can I install pip within a embedded python environment.

Traceback (most recent call last): File ".\getpip.py", line 20061, in main() File ".\getpip.py", line 194, in main bootstrap(tmpdir=tmpdir) File ".\getpip.py", line 82, in bootstrap import pip File "", line 961, in _find_and_load File "", line 950, in _find_and_load_unlocked File "", line 646, in _load_unlocked File "", line 616, in _load_backward_compatible

The directory structure is:

Directory: C:\Downloads\python-3.6.1rc1-embed-win32  Mode                LastWriteTime         Length Name ----                -------------         ------ ---- -a----         3/4/2017   7:26 PM         157344 pyexpat.pyd -a----         3/4/2017   7:26 PM          97952 python.exe -a----         3/4/2017   7:26 PM          58016 python3.dll -a----         3/4/2017   7:26 PM        3263648 python36.dll -a----         3/4/2017   7:26 PM        2209284 python36.zip -a----         3/4/2017   7:26 PM             79 python36._pth -a----         3/4/2017   7:26 PM          96416 pythonw.exe -a----         3/4/2017   7:26 PM          23200 select.pyd -a----         3/4/2017   7:26 PM         866464 sqlite3.dll -a----         3/4/2017   7:26 PM         895648 unicodedata.pyd -a----         3/4/2017   7:26 PM          83784 vcruntime140.dll -a----         3/4/2017   7:26 PM          24224 winsound.pyd -a----         3/4/2017   7:26 PM          45216 _asyncio.pyd -a----         3/4/2017   7:26 PM          77984 _bz2.pyd -a----         3/4/2017   7:26 PM         101536 _ctypes.pyd -a----         3/4/2017   7:26 PM         215712 _decimal.pyd -a----         3/4/2017   7:26 PM         156832 _elementtree.pyd -a----         3/4/2017   7:26 PM        1042592 _hashlib.pyd -a----         3/4/2017   7:26 PM         183456 _lzma.pyd -a----         3/4/2017   7:26 PM          32416 _msi.pyd -a----         3/4/2017   7:26 PM          25760 _multiprocessing.pyd -a----         3/4/2017   7:26 PM          33952 _overlapped.pyd -a----         3/4/2017   7:26 PM          61600 _socket.pyd -a----         3/4/2017   7:26 PM          64160 _sqlite3.pyd -a----         3/4/2017   7:26 PM        1458848 _ssl.pyd 
like image 931
fluter Avatar asked Mar 08 '17 08:03

fluter


People also ask

What is embedded Python?

The simplest form of embedding Python is the use of the very high level interface. This interface is intended to execute a Python script without needing to interact with the application directly. This can for example be used to perform some operation on a file.

What is Python embedded version?

4.4. The embeddable package. New in version 3.5. 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.


2 Answers

Even if explicitly stated that the embeddable version of Python does not support Pip, it is possible with care. You need to:

  1. Download and unzip Python embeddable zip file.

  2. In the file python39._pth or similar, uncomment the import command. Result should look similar to this:

    python39.zip . import site 
  3. Download get-pip.py to the Python install folder

  4. Run get-pip.py. this installs Pip into the Scripts directory:

    python get-pip.py 
  5. Run Pip directly from command line as Pip is a executable program (this example is to install Pandas):

    .\Scripts\pip install pandas 

You could find more information about this in the Pip issue 4207

like image 152
oyon Avatar answered Oct 08 '22 02:10

oyon


how I installed pip into an embeddable python distribution:

  1. unpack the python embeddable distro archive and cd there
  2. run python ./get-pip.py (got here)
  3. EITHER just uncomment string import site inside file pythonXX._pth OR copy folders (at least pip) from the newly-created folder Lib/site-packages/ into pythonXX.zip

now it's possible to python -m pip ...

like image 26
alexey Avatar answered Oct 08 '22 02:10

alexey