Thanks for visiting the site !!! Visit below intrested Ads to support us if you like the site .Sharing is caring .keep distance and keep safe . Happy Learning ... πŸ˜€

Download Embeded version of Python and install modules using pip

Python is available as an embedded distribution for Windows. Download the required version as shown below

https://www.python.org/downloads/windows/

Below notes for installing 3rd party modules in python using pip. This worked for both the 32-bit and 64-bit versions of Python 3.X.

In the path configuration file (in the Python 3.8 distribution: β€˜python38._pth’), uncomment the last line to import site

Download get-pip.py and install pip> python get-pip.py

https://bootstrap.pypa.io/get-pip.py

You can now install import third-party packages with: > python.exe -m pip install ... where ... is the list of package names

To set the sys.path variable open the _pth file an add the following pathes at the and of the file. Replace β€œD:\Python3.8” with your installation directory.

D:\Python3.8
D:\Python3.8\DLLs
D:\Python3.8\lib
D:\Python3.8\lib\plat-win
D:\Python3.8\lib\site-packages

run python.exe -m pip

C:\Users\ame\Desktop\Python\python-3.8.7-embed-amd64>python.exe -m pip

Usage:
  C:\Users\ame\Desktop\Python\python-3.8.7-embed-amd64\python.exe -m pip <command> [options]

Commands:
  install                     Install packages.
  download                    Download packages.
  uninstall                   Uninstall packages.
  freeze                      Output installed packages in requirements format.
  list                        List installed packages.
  show                        Show information about installed packages.
  check                       Verify installed packages have compatible dependencies.
  config                      Manage local and global configuration.
  search                      Search PyPI for packages.
  cache                       Inspect and manage pip's wheel cache.
  wheel                       Build wheels from your requirements.
  hash                        Compute hashes of package archives.
  completion                  A helper command used for command completion.
  debug                       Show information useful for debugging.
  help                        Show help for commands.

General Options:
  -h, --help                  Show help.
  --isolated                  Run pip in an isolated mode, ignoring environment variables and user configuration.
  -v, --verbose               Give more output. Option is additive, and can be used up to 3 times.
  -V, --version               Show version and exit.
  -q, --quiet                 Give less output. Option is additive, and can be used up to 3 times (corresponding to WARNING, ERROR, and CRITICAL logging levels).
  --log <path>                Path to a verbose appending log.
  --no-input                  Disable prompting for input.
  --proxy <proxy>             Specify a proxy in the form [user:passwd@]proxy.server:port.
  --retries <retries>         Maximum number of retries each connection should attempt (default 5 times).
  --timeout <sec>             Set the socket timeout (default 15 seconds).
  --exists-action <action>    Default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup, (a)bort.
  --trusted-host <hostn>   Mark this host or host:port pair as trusted, even though it does not have valid or any HTTPS.
  --cert <path>               Path to alternate CA bundle.
  --client-cert <path>        Path to SSL client certificate, a single file containing the private key and the certificate in PEM format.
  --cache-dir <dir>           Store the cache data in <dir>.
  --no-cache-dir              Disable the cache.
  --disable-pip-version-check
                              Don't periodically check PyPI to determine whether a new version of pip is available for download. Implied with --no-index.
  --no-color                  Suppress colored output.
  --no-python-version-warning
                              Silence deprecation warnings for upcoming unsupported Pythons.
  --use-feature <feature>     Enable new functionality, that may be backward incompatible.
  --use-deprecated <feature>  Enable deprecated functionality, that will be removed in the future.

C:\Users\ame\Desktop\Python\python-3.8.7-embed-amd64>

When i try to install pip3.8.exe install ssl .got below error

Tried to install x509 using pip3

C:\Python\Scripts>pip3.8.exe install ssl
Collecting ssl
  Using cached ssl-1.16.tar.gz (33 kB)
    ERROR: Command errored out with exit status 1:
     command: 'c:\python\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\ame\\AppData\\Local\\Temp\\pip-install-jbttti_r\\ssl_5aa1c28ec3084846a15f6344823d964a\\setup.py'"'"'; __file__='"'"'C:\\Users\\Thathekalv
a\\AppData\\Local\\Temp\\pip-install-jbttti_r\\ssl_5aa1c28ec3084846a15f6344823d964a\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exe
c'"'"'))' egg_info --egg-base 'C:\Users\ame\AppData\Local\Temp\pip-pip-egg-info-tlm5gsp4'
         cwd: C:\Users\ame\AppData\Local\Temp\pip-install-jbttti_r\ssl_5aa1c28ec3084846a15f6344823d964a\
    Complete output (6 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\ame\AppData\Local\Temp\pip-install-jbttti_r\ssl_5aa1c28ec3084846a15f6344823d964a\setup.py", line 33
        print 'looking for', f
              ^
    SyntaxError: Missing parentheses in call to 'print'. Did you mean print('looking for', f)?
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

C:\Python\Scripts>

But i understand ssl module is not there in python 3. Tried to install x509 .it is successfully installed

C:\Python\Scripts>pip3.8.exe install x509

Collecting x509
  Downloading x509-0.1.tar.gz (28 kB)
Collecting pyasn1>=0.1.7
  Downloading pyasn1-0.4.8-py2.py3-none-any.whl (77 kB)
     |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 77 kB 345 kB/s
Building wheels for collected packages: x509
  Building wheel for x509 (setup.py) ... done
  Created wheel for x509: filename=x509-0.1-py3-none-any.whl size=44540 sha256=87be03134fb096120f2525f4c2e3d769bbe36852c5ffa49144df21216ea046d0
  Stored in directory: c:\users\ame\appdata\local\pip\cache\wheels\40\8b\18\3643897439b9d44cde16aec8104165c56ae5167512bb5c6df8
Successfully built x509
Installing collected packages: pyasn1, x509
  WARNING: The scripts pkcs7_parse.exe and x509_parse.exe are installed in 'c:\python\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed pyasn1-0.4.8 x509-0.1

C:\Python\Scripts>

Once the required moduels will be loaded from the below location lib\site-packages\xxx\__init__.py

Now the entire package we can zip and upload to any server to run our the python script which has the dependency with modules already installed

Installing pyOpenSSL with pip

C:\Python\Scripts>pip3.8.exe install pyOpenSSL
Collecting pyOpenSSL
  Downloading pyOpenSSL-20.0.1-py2.py3-none-any.whl (54 kB)
     |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 54 kB 242 kB/s
Collecting cryptography>=3.2
  Using cached cryptography-3.3.1-cp36-abi3-win_amd64.whl (1.5 MB)
Collecting cffi>=1.12
  Using cached cffi-1.14.4-cp38-cp38-win_amd64.whl (179 kB)
Collecting six>=1.5.2
  Downloading six-1.15.0-py2.py3-none-any.whl (10 kB)
Collecting pycparser
  Downloading pycparser-2.20-py2.py3-none-any.whl (112 kB)
     |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 112 kB 3.3 MB/s
Installing collected packages: pycparser, six, cffi, cryptography, pyOpenSSL
Successfully installed cffi-1.14.4 cryptography-3.3.1 pyOpenSSL-20.0.1 pycparser

C:\Python\Scripts>cd ..

Leave a Reply

Your email address will not be published. Required fields are marked *