Python pip issue


#1

I tried using pip to install SQLAlchemy, but it gives me the following error:

pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting SQLAlchemy
  Could not fetch URL https://pypi.python.org/simple/sqlalchemy/: There was a problem confirming the ssl certificate: Can't connect to HTTPS URL because the SSL module is not available. - skipping
  Could not find a version that satisfies the requirement SQLAlchemy (from versions: )
No matching distribution found for SQLAlchemy

I know that I am probably missing some package or something but I am not sure what packages I need to intall.

I am using pyenv and pyenv-virtualenv for managing the virtual envirenment; and I have successfully installed a library (lxml) using pip in the same virtual envirenment before.


#2

Try installing python2-pyopenssl or python-pyopenssl if you are using python 3.


#3

Thanks for the reply!

I tried installing the mentioned packages in addition to python-pip, but the error still exists.

Also, I am using python 3.6


#4
sudo pacman -S python-sqlalchemy

Or am I missing something?


#5

That would just install it globally, wouldn’t it?

I am using a virtual environment. I want to use pip to install the libraries I need inside the environment not on the system.


#6

Why not use Anaconda for setting up python virtual environments?


#7

I program in python, never understood virtualenvs :smiley: @AlManja tried to explain them to me.

I just created a virtual environment from:
http://docs.python-guide.org/en/latest/dev/virtualenvs/

Then ran the example main.py - it worked.

Then I installed sqlalchemy with

pipenv install sqlalchemy

It worked. So I have the correct dependencies (from somewhere).

It does not appear to have many dependencies though:

pacman -Qi python-sqlalchemy                                                                                        1 ↵  19:26:49 
Name            : python-sqlalchemy
Version         : 1.1.14-1
Description     : Python SQL toolkit and Object Relational Mapper
Architecture    : x86_64
URL             : http://www.sqlalchemy.org/
Licenses        : MIT
Groups          : None
Provides        : None
Depends On      : python
Optional Deps   : python-psycopg2: connect to PostgreSQL database [installed]
Required By     : python-sphinx
Optional For    : python-pandas
Conflicts With  : None
Replaces        : None
Installed Size  : 7.48 MiB
Packager        : Jelle van der Waa <jelle@archlinux.org>
Build Date      : Fri 15 Sep 2017 17:12:53 BST
Install Date    : Sat 16 Sep 2017 13:57:18 BST
Install Reason  : Explicitly installed
Install Script  : No
Validated By    : Signature

Install globally - you can always remove, then retry in the virtual env.


#8

Thanks for the reply:)

I solved my problem by simply creating a new virtual environment. I guess the one I used essentially had a corrupted pip or something.

I don’t know much about Anaconda, but from what I know, it’s a data science toolkit combining several heavy libraries. And that would be overkill since I don’t want any of those libraries.

I use Pyenv which is actually a python version manager (it allows you to switch between python versions the same way you can switch between virtual environments) with the pyenv-virtualenv plugin which allows you to manage the virtual environments in a simple and lightweight way.


#9

HOORAY! Someone doing it properly. :wink:


#10

Thanks for trying to help Steve I solved the problem, see my reply to @bayone :smile:

As for virtual environments, let me try and explain with my limited knowledge.

If you install a library globally, the installation might affect the entire system, for example, if the library you installed allows for whatever reason to use a command called pacman (or any other existing command) that might create some conflicts with the existing system package that provides the same command.

Creating a virtual environment and installing libraries inside it gives you a controllable box where you know for certain the conditions your Python program runs on, this includes all the installed libraries, their versions and much more; you can easily recreate the same environment on any other machine. That solves the problem of “It works on my machine!”[1], which is one of the biggest reasons it is encouraged that you use a virtual environment.

The basic idea of virtual environments is isolating your python programs from everything else on the OS. in other words, if you install something on a particular virtual environment, you can only access whatever you installed inside the said environment which means you can’t access it anywhere else. and that reduces the problems related to package conflicts.

Furthermore, with virtual environments you can use multiple versions of the same library across different projects. for example, Project A can use SQLAlchemy 1.1 and Project B can use SQLAlchemy 1.2 without any of the projects knowing about what the other one uses.

So all in all, virtual environments are essential for any Python project, because installing stuff globally might cause some serious damage. And environments allow you to control the overall process of crafting your beautiful product :smile:


[1] That moment when you successfully finish your program and everything works as expected, only to get a load of errors when you install it on your friend’s computer.


#11

Thank you!

I wrote an explanation on why we should use virtual environments in a reply to @xircon. Though, I am not confident everything I said was accurate, can you please check it out and point out any mistakes or give additional info :slight_smile:?


#12

Looks about right to me. :slight_smile:


#13

Aaarrrrgggh! Ignore my post please. I didn’t read your post with enough attention. You are talking about “python version manager” I see. Sry, but I will leave it here for anyone else maybe interested in virtual environments

Since you are already familiar with it and it works for you, that’s probably all you need now :wink: but I will add this anyway.

Since 3.4 or was it 3.5(?) python has now natively build in support for virtual environments. So if you want to avoid using third party packages, you can use this command [inside your project folder]:

python -m venv myvenv

“myvenv” is folder where your virtual environment will be installed. Probably best way is to just install it inside your project folder. So if you sometime in the future delete your project folder, you will delete it’s virtual environment with it also. Helps with virtual environment management also :slight_smile:

This command sets your current python version into virtual environment.

Then you have to activate it of course before installing/removing packages:

source /home/USER/my_project/myvenv/bin/activate


#14

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.