Portable python - can't install pip
pip, portable-python
Solution
Ok, if by Portable Python you mean the embeddable zip file that Python.org provides, than this guide solved my problem: https://michlstechblog.info/blog/python-install-python-with-pip-on-windows-by-the-embeddable-zip-file/
Here's the text in case it goes offline:
To install Python on Windows download the latest version. In this example Python 3.6.5.
Extract the zip file to an directory, e.g. D:\python3.6.5.
To install pip download the latest version of get-pip to the pythons install path and start installation.
> d:\> cd /d D:\Python3.6.5 D:\Python3.6.5> python get-pip.py ...
> Installing collected packages: pip, setuptools, wheel Successfully
> installed pip-10.0.1 setuptools-39.2.0 wheel-0.31.1
If you are behind a proxy add the –proxy switch
D:\Python3.6.5> python get-pip.py --proxy="http://192.168.254.1:8888"
Unfortunately in the default configuration you can not load any module installed by pip, pip itself too. Because the sys.path variable just contains Python Zip file and the path to the python directory where the python executable is located.
>>> import sys
>>> print(sys.path)
['D:\\Python3.6.5\\python36.zip', 'D:\\Python3.6.5']
>>> import pip
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pip'
Any try to expand the variable by setting a PYTHONPATH variable are ignored. Root cause is that the embeddable zip file installation package contains a file python36._pth which overwrites all other possibilities to set the sys.path variable. sys.path contains all directories where python looks for modules.
To set the sys.path variable open the _pth file an add the following pathes at the and of the file. Replace “D:\Python3.6.5” with your installation directory.
D:\Python3.6.5
D:\Python3.6.5\DLLs
D:\Python3.6.5\lib
D:\Python3.6.5\lib\plat-win
D:\Python3.6.5\lib\site-packages
Or rename the python36._pth file
D:\Python3.6.5> ren python36._pth python36._pth.save
and set the PYTHONPATH environment variable for the current user.
setx PYTHONPATH "D:\Python3.6.5;D:\Python3.6.5\DLLs;D:\Python3.6.5\lib;D:\Python3.6.5\lib\plat-win;D:\Python3.6.5\lib\site-packages"
or for the whole system
setx /M PYTHONPATH "D:\Python3.6.5;D:\Python3.6.5\DLLs;D:\Python3.6.5\lib;D:\Python3.6.5\lib\plat-win;D:\Python3.6.5\lib\site-packages"
Problem
I'm trying to get pip on my USB drive. Following the instructions on this web sit, I downloaded `get-pip.py` and run `python get-pip.py` (`python` is in the environment path). Unfortunately the script through an error. I have uploaded the log file to here. The error itself is: ``` Exception: Traceback (most recent call last): File "c:\users\elyashic\appdata\local\temp\tmprkcrtx\pip.zip\pip\_vendor\pkg_resources.py", line 2251, in parsed_version return self._parsed_version File "c:\users\elyashic\appdata\local\temp\tmprkcrtx\pip.zip\pip\_vendor\pkg_resources.py", line 2344, in __getattr__ raise AttributeError(attr) AttributeError: _parsed_version During handling of the above exception, another exception occurred: Traceback (most recent call last): File "c:\users\elyashic\appdata\local\temp\tmprkcrtx\pip.zip\pip\_vendor\pkg_resources.py", line 2259, in version return self._version File "c:\users\elyashic\appdata\local\temp\tmprkcrtx\pip.zip\pip\_vendor\pkg_resources.py", line 2344, in __getattr__ raise AttributeError(attr) AttributeError: _version During handling of the above exception, another exception occurred: Traceback (most recent call last): File "c:\users\elyashic\appdata\local\temp\tmprkcrtx\pip.zip\pip\basecommand.py", line 122, in main status = self.run(options, args) File "c:\users\elyashic\appdata\local\temp\tmprkcrtx\pip.zip\pip\commands\install.py", line 283, in run requirement_set.install(install_options, global_options, root=options.root_path) File "c:\users\elyashic\appdata\local\temp\tmprkcrtx\pip.zip\pip\req.py", line 1420, in install if existing_distribute in distribute_requirement: File "c:\users\elyashic\appdata\local\temp\tmprkcrtx\pip.zip\pip\_vendor\pkg_resources.py", line 2643, in __contains__ if self.index: item = item.parsed_version # only get if we need it File "c:\users\elyashic\appdata\local\temp\tmprkcrtx\pip.zip\pip\_vendor\pkg_resources.py", line 2253, in parsed_version self._parsed_version = pv = parse_version(self.version) File "c:\users\elyashic\appdata\local\temp\tmprkcrtx\pip.zip\pip\_vendor\pkg_resources.py", line 2267, in version "Missing 'Version:' header and/or %s file" % self.PKG_INFO, self ValueError: ("Missing 'Version:' header and/or PKG-INFO file", distribute [unknown version] (i:\portableapps\portable python 3.2.5.1\app\scripts)) ``` Can any one explain to me what I did wrong? I'm using portable python 3.2.5.1, and it was fresh from the installation until I tried installing pip.