Collage

n. A piece of art made by sticking various different materials, aka PHENOMENA Magazine
Department
python

python

Fix SSL error when install packages using pip
Q : pip install fails with "connection error: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:598)"   A : pip install gensim config --global http.sslVerify false Just install any package with the "config --global http.sslVerify false" statement You can ignore SSL errors by setting pypi.org and files.pythonhosted.org as well as the older pypi.python.org as trusted hosts. $ pip install --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org <package_name> Note: Sometime during April 2018, the Python Package Index was migrated from pypi.python.org to pypi.org. This means "trusted-host" commands using the old domain no longer work, but you can add both. Permanent Fix Since the release of pip 10.0, you should be able to fix this permanently just by upgrading pip itself: $ pip install --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org pip setuptools Or by just reinstalling it to get the latest version: $ curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py (… and then running get-pip.py with the relevant Python interpreter). pip install <otherpackage> should just work after this. If not, then you will need to do more, as explained below. You may want to add the trusted hosts and proxy to your config file. pip.ini (Windows) or pip.conf (unix) [global] trusted-host = pypi.python.org pypi.org files.pythonhosted.org Alternate Solutions (Less secure) Most of the answers could pose a security issue. Two of the workarounds that help in installing most of the python packages with ease would be: Using easy_install: if you are really lazy and don't want to waste much time, use easy_install <package_name>. Note that some packages won't be found or will give small errors. Using Wheel: download the Wheel of the python package and use the pip command pip install wheel_package_name.whl to install the package. https://stackoverflow.com/questions/25981703/pip-install-fails-with-connection-error-ssl-certificate-verify-failed-certi/26062583 
python · Jan. 12, 2023, 3:28 a.m.
ssl pip
How do I check which version of Python is running my script?
This information is available in the sys.version string in the sys module: >>> import sys Human readable: >>> print(sys.version) # parentheses necessary in python 3. 2.5.2 (r252:60911, Jul 31 2008, 17:28:52) [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] For further processing, use sys.version_info or sys.hexversion: >>> sys.version_info (2, 5, 2, 'final', 0) # or >>> sys.hexversion 34014192 To ensure a script runs with a minimal version requirement of the Python interpreter add this to your code: assert sys.version_info >= (2, 5) This compares major and minor version information. Add micro (=0, 1, etc) and even releaselevel (='alpha','final', etc) to the tuple as you like. Note however, that it is almost always better to "duck" check if a certain feature is there, and if not, workaround (or bail out). Sometimes features go away in newer releases, being replaced by others. or Use platform's python_version from the stdlib: from platform import python_version print(python_version()) # 3.9.2 https://stackoverflow.com/questions/1093322/how-do-i-check-which-version-of-python-is-running-my-script
python · Jan. 12, 2023, 1:19 a.m.
  • 1
  • 2 (current)