When I wanted to install pip, the error just came out:
C:\Users\xd>python get-pip.py install
Collecting install
Exception:
Traceback (most recent call last):
File "C:\Users\xd\AppData\Local\Temp\tmpf2uneu6f\pip.zip\pip\basecommand.py", line 215, in main
status = self.run(options, args)
File "C:\Users\xd\AppData\Local\Temp\tmpf2uneu6f\pip.zip\pip\commands\install.py", line 324, in run
requirement_set.prepare_files(finder)
File "C:\Users\xd\AppData\Local\Temp\tmpf2uneu6f\pip.zip\pip\req\req_set.py", line 380, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File "C:\Users\xd\AppData\Local\Temp\tmpf2uneu6f\pip.zip\pip\req\req_set.py", line 554, in _prepare_file
require_hashes
File "C:\Users\xd\AppData\Local\Temp\tmpf2uneu6f\pip.zip\pip\req\req_install.py", line 278, in populate_link
self.link = finder.find_requirement(self, upgrade)
File "C:\Users\xd\AppData\Local\Temp\tmpf2uneu6f\pip.zip\pip\index.py", line 465, in find_requirement
all_candidates = self.find_all_candidates(req.name)
File "C:\Users\xd\AppData\Local\Temp\tmpf2uneu6f\pip.zip\pip\index.py", line 423, in find_all_candidates
for page in self._get_pages(url_locations, project_name):
File "C:\Users\xd\AppData\Local\Temp\tmpf2uneu6f\pip.zip\pip\index.py", line 568, in _get_pages
page = self._get_page(location)
File "C:\Users\xd\AppData\Local\Temp\tmpf2uneu6f\pip.zip\pip\index.py", line 683, in _get_page
return HTMLPage.get_page(link, session=self.session)
File "C:\Users\xd\AppData\Local\Temp\tmpf2uneu6f\pip.zip\pip\index.py", line 792, in get_page
"Cache-Control": "max-age=600",
File "C:\Users\xd\AppData\Local\Temp\tmpf2uneu6f\pip.zip\pip\_vendor\requests\sessions.py", line 488, in get
return self.request('GET', url, **kwargs)
File "C:\Users\xd\AppData\Local\Temp\tmpf2uneu6f\pip.zip\pip\download.py", line 386, in request
return super(PipSession, self).request(method, url, *args, **kwargs)
File "C:\Users\xd\AppData\Local\Temp\tmpf2uneu6f\pip.zip\pip\_vendor\requests\sessions.py", line 475, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\xd\AppData\Local\Temp\tmpf2uneu6f\pip.zip\pip\_vendor\requests\sessions.py", line 596, in send
r = adapter.send(request, **kwargs)
File "C:\Users\xd\AppData\Local\Temp\tmpf2uneu6f\pip.zip\pip\_vendor\cachecontrol\adapter.py", line 47, in send
resp = super(CacheControlAdapter, self).send(request, **kw)
File "C:\Users\xd\AppData\Local\Temp\tmpf2uneu6f\pip.zip\pip\_vendor\requests\adapters.py", line 423, in send
timeout=timeout
File "C:\Users\xd\AppData\Local\Temp\tmpf2uneu6f\pip.zip\pip\_vendor\requests\packages\urllib3\connectionpool.py", line 589, in urlopen
self._prepare_proxy(conn)
File "C:\Users\xd\AppData\Local\Temp\tmpf2uneu6f\pip.zip\pip\_vendor\requests\packages\urllib3\connectionpool.py", line 797, in _prepare_proxy
conn.connect()
File "C:\Users\xd\AppData\Local\Temp\tmpf2uneu6f\pip.zip\pip\_vendor\requests\packages\urllib3\connection.py", line 254, in connect
conn = self._new_conn()
File "C:\Users\xd\AppData\Local\Temp\tmpf2uneu6f\pip.zip\pip\_vendor\requests\packages\urllib3\connection.py", line 142, in _new_conn
(self.host, self.port), self.timeout, **extra_kw)
File "C:\Users\xd\AppData\Local\Temp\tmpf2uneu6f\pip.zip\pip\_vendor\requests\packages\urllib3\util\connection.py", line 66, in create_connection
if host.startswith('['):
AttributeError: 'NoneType' object has no attribute 'startswith'
What can I do?
For recent Python versions (3.4+), you don't need to use the get-pip.py script anymore. Just run python -m ensurepip, and the ensurepip module will do everything the get-pip.py script used to do.
Related
The problem
On a fresh and minimal Ubuntu 20.04 installation with ufw inactive:
pip3 fails with HTTPSConnectionPool timeout.
pip3 fails to install or update any package in a freshly installed OS.
pip3 fails with the same error when installing local wheel files.
pip3 fails in both a virtual python environment and at the system-level environment.
Environment
Ubuntu 20.04 LTS
fresh install,
apt updated/upgraded
Python 3.8
Additional details
--default-timeout=100
--default-timeout=1000
UPDATE:
Traceback after user-interrupt python -m pip install -U pip
^CERROR: Operation cancelled by user
^CTraceback (most recent call last):
File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/home/zippy/Documents/python_workspace/py_virt_env/lib/python3.8/site-packages/pip/__main__.py", line 26, in <module>
sys.exit(_main())
File "/home/zippy/Documents/python_workspace/py_virt_env/lib/python3.8/site-packages/pip/_internal/cli/main.py", line 75, in main
return command.main(cmd_args)
File "/home/zippy/Documents/python_workspace/py_virt_env/lib/python3.8/site-packages/pip/_internal/cli/base_command.py", line 114, in main
return self._main(args)
File "/home/zippy/Documents/python_workspace/py_virt_env/lib/python3.8/site-packages/pip/_internal/cli/base_command.py", line 226, in _main
self.handle_pip_version_check(options)
File "/home/zippy/Documents/python_workspace/py_virt_env/lib/python3.8/site-packages/pip/_internal/cli/req_command.py", line 158, in handle_pip_version_check
pip_self_version_check(session, options)
File "/home/zippy/Documents/python_workspace/py_virt_env/lib/python3.8/site-packages/pip/_internal/self_outdated_check.py", line 207, in pip_self_version_check
best_candidate = finder.find_best_candidate("pip").best_candidate
File "/home/zippy/Documents/python_workspace/py_virt_env/lib/python3.8/site-packages/pip/_internal/index/package_finder.py", line 883, in find_best_candidate
candidates = self.find_all_candidates(project_name)
File "/home/zippy/Documents/python_workspace/py_virt_env/lib/python3.8/site-packages/pip/_internal/index/package_finder.py", line 827, in find_all_candidates
package_links = self.process_project_url(
File "/home/zippy/Documents/python_workspace/py_virt_env/lib/python3.8/site-packages/pip/_internal/index/package_finder.py", line 792, in process_project_url
html_page = self._link_collector.fetch_page(project_url)
File "/home/zippy/Documents/python_workspace/py_virt_env/lib/python3.8/site-packages/pip/_internal/index/collector.py", line 612, in fetch_page
return _get_html_page(location, session=self.session)
File "/home/zippy/Documents/python_workspace/py_virt_env/lib/python3.8/site-packages/pip/_internal/index/collector.py", line 451, in _get_html_page
resp = _get_html_response(url, session=session)
File "/home/zippy/Documents/python_workspace/py_virt_env/lib/python3.8/site-packages/pip/_internal/index/collector.py", line 149, in _get_html_response
resp = session.get(
File "/home/zippy/Documents/python_workspace/py_virt_env/lib/python3.8/site-packages/pip/_vendor/requests/sessions.py", line 543, in get
return self.request('GET', url, **kwargs)
File "/home/zippy/Documents/python_workspace/py_virt_env/lib/python3.8/site-packages/pip/_internal/network/session.py", line 421, in request
return super(PipSession, self).request(method, url, *args, **kwargs)
File "/home/zippy/Documents/python_workspace/py_virt_env/lib/python3.8/site-packages/pip/_vendor/requests/sessions.py", line 530, in request
resp = self.send(prep, **send_kwargs)
File "/home/zippy/Documents/python_workspace/py_virt_env/lib/python3.8/site-packages/pip/_vendor/requests/sessions.py", line 643, in send
r = adapter.send(request, **kwargs)
File "/home/zippy/Documents/python_workspace/py_virt_env/lib/python3.8/site-packages/pip/_vendor/cachecontrol/adapter.py", line 53, in send
resp = super(CacheControlAdapter, self).send(request, **kw)
File "/home/zippy/Documents/python_workspace/py_virt_env/lib/python3.8/site-packages/pip/_vendor/requests/adapters.py", line 439, in send
resp = conn.urlopen(
File "/home/zippy/Documents/python_workspace/py_virt_env/lib/python3.8/site-packages/pip/_vendor/urllib3/connectionpool.py", line 665, in urlopen
httplib_response = self._make_request(
File "/home/zippy/Documents/python_workspace/py_virt_env/lib/python3.8/site-packages/pip/_vendor/urllib3/connectionpool.py", line 376, in _make_request
self._validate_conn(conn)
File "/home/zippy/Documents/python_workspace/py_virt_env/lib/python3.8/site-packages/pip/_vendor/urllib3/connectionpool.py", line 994, in _validate_conn
conn.connect()
File "/home/zippy/Documents/python_workspace/py_virt_env/lib/python3.8/site-packages/pip/_vendor/urllib3/connection.py", line 352, in connect
self.sock = ssl_wrap_socket(
File "/home/zippy/Documents/python_workspace/py_virt_env/lib/python3.8/site-packages/pip/_vendor/urllib3/util/ssl_.py", line 370, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File "/usr/lib/python3.8/ssl.py", line 500, in wrap_socket
return self.sslsocket_class._create(
File "/usr/lib/python3.8/ssl.py", line 1040, in _create
self.do_handshake()
File "/usr/lib/python3.8/ssl.py", line 1309, in do_handshake
self._sslobj.do_handshake()
KeyboardInterrupt
UPDATE
Sanity check - OK
laptop082:468$ curl https://pypi.org:443/simple/pip/
<!DOCTYPE html>
<html>
<head>
<meta name="pypi:repository-version" content="1.0">
<title>Links for pip</title>
</head>
<body>
<h1>Links for pip</h1>
pip-0.2.tar.gz<br/>
.
.
.
Questions
What are my options?
Will a Ubuntu re-install be necessary?
UPDATE:
Re-installation of Ubuntu 20.04 did not resolve the problem.
Please advise.
I have set up Airflow on an AWS EC2 server with Ubuntu 18.04, Python 3.6.9. The DB backend is a 5.7.26 MySQL, I am using a LocalExecutor. The setup is nothing more than:
apt-get install python3 python3-pip python3-venv libmysqlclient-dev
I install Airflow with pip3 install apache-airflow[mysql]==1.10.9, init DB connection, start the webserver and it works both normally and with -D. The scheduler, however, works only when run in the foreground. Trying to run it as a daemon fails with the following trace:
Traceback (most recent call last):
File "/usr/local/bin/airflow", line 37, in <module> args.func(args)
File "/usr/local/lib/python3.6/dist-packages/airflow/utils/cli.py", line 75, in wrapper return f(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/airflow/bin/cli.py", line 1032, in schedulerjob.run()
File "/usr/local/lib/python3.6/dist-packages/airflow/jobs/base_job.py", line 215, in run session.commit()
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/session.py", line 1036, in commit self.transaction.commit()
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/session.py", line 503, in commitself._prepare_impl()
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/session.py", line 482, in _prepare_impl self.session.flush()
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/session.py", line 2496, in flushself._flush(objects)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/session.py", line 2637, in _flush transaction.rollback(_capture_exception=True)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/util/langhelpers.py", line 69, in __exit__exc_value, with_traceback=exc_tb,
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/util/compat.py", line 178, in raise_raise exception
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/session.py", line 2597, in _flush flush_context.execute()
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/unitofwork.py", line 422, in execute rec.execute(self)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/unitofwork.py", line 589, in execute uow,
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/persistence.py", line 213, in save_obj) in _organize_states_for_save(base_mapper, states, uowtransaction):
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/persistence.py", line 374, in _organize_states_for_save base_mapper, uowtransaction, states
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/persistence.py", line 1602, in _connections_for_states connection = uowtransaction.transaction.connection(base_mapper)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/session.py", line 313, in connection return self._connection_for_bind(bind, execution_options)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/session.py", line 420, in _connection_for_bind conn = self._parent._connection_for_bind(bind, execution_options)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/orm/session.py", line 432, in _connection_for_bind conn = bind._contextual_connect()
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/engine/base.py", line 2251, in _contextual_connect self._wrap_pool_connect(self.pool.connect, None),
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/engine/base.py", line 2285, in _wrap_pool_connect return fn()
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/pool/base.py", line 363, in connect return _ConnectionFairy._checkout(self)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/pool/base.py", line 804, in _checkout result = pool._dialect.do_ping(fairy.connection)
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/dialects/mysql/mysqldb.py", line 138, in do_pingdbapi_connection.ping(False)
File "/usr/local/lib/python3.6/dist-packages/pymysql/connections.py", line 546, in ping self._execute_command(COMMAND.COM_PING, "")
File "/usr/local/lib/python3.6/dist-packages/pymysql/connections.py", line 771, in _execute_command self._write_bytes(packet)
File "/usr/local/lib/python3.6/dist-packages/pymysql/connections.py", line 711, in _write_bytesself._sock.settimeout(self._write_timeout)
OSError: [Errno 9] Bad file descriptor
Exception ignored in: <function _ConnectionRecord.checkout.<locals>.<lambda> at 0x7f2eb025e268>
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/pool/base.py", line 503, in <lambda>
File "/usr/local/lib/python3.6/dist-packages/sqlalchemy/pool/base.py", line 702, in _finalize_fairy
File "/usr/lib/python3.6/logging/__init__.py", line 1337, in error
File "/usr/lib/python3.6/logging/__init__.py", line 1444, in _log
File "/usr/lib/python3.6/logging/__init__.py", line 1454, in handle
File "/usr/lib/python3.6/logging/__init__.py", line 1516, in callHandlers
File "/usr/lib/python3.6/logging/__init__.py", line 865, in handle
File "/usr/lib/python3.6/logging/__init__.py", line 1071, in emit
File "/usr/lib/python3.6/logging/__init__.py", line 1061, in _open
NameError: name 'open' is not defined
I am trying to set up a server for semi-production purposes, so this is actually a blocker for me. I would be grateful for any advice.
EDIT
I tried using mysql-connector-python==8.0.18 and the scheduler did run as a daemon, but an attempt to open a dag failed with the following trace:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0: invalid start byte
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.6/dist-packages/flask/_compat.py", line 39, in reraise
raise value
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1936, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/usr/local/lib/python3.6/dist-packages/flask_admin/base.py", line 69, in inner
return self._run_view(f, *args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/flask_admin/base.py", line 368, in _run_view
return fn(self, *args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/flask_login/utils.py", line 258, in decorated_view
return func(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/airflow/www/utils.py", line 384, in view_func
return f(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/airflow/www/utils.py", line 290, in wrapper
return f(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/airflow/utils/db.py", line 74, in wrapper
return func(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/airflow/www/views.py", line 1559, in tree
start_date=min_date, end_date=base_date, session=session)
File "/usr/local/lib/python3.6/dist-packages/airflow/utils/db.py", line 70, in wrapper
return func(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/airflow/models/dag.py", line 837, in get_task_instances
tis = tis.order_by(TaskInstance.execution_date).all()
File "/home/ubuntu/.local/lib/python3.6/site-packages/sqlalchemy/orm/query.py", line 3233, in all
return list(self)
File "/home/ubuntu/.local/lib/python3.6/site-packages/sqlalchemy/orm/query.py", line 3389, in __iter__
return self._execute_and_instances(context)
File "/home/ubuntu/.local/lib/python3.6/site-packages/sqlalchemy/orm/query.py", line 3414, in _execute_and_instances
result = conn.execute(querycontext.statement, self._params)
File "/home/ubuntu/.local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 982, in execute
return meth(self, multiparams, params)
File "/home/ubuntu/.local/lib/python3.6/site-packages/sqlalchemy/sql/elements.py", line 293, in _execute_on_connection
return connection._execute_clauseelement(self, multiparams, params)
File "/home/ubuntu/.local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1101, in _execute_clauseelement
distilled_params,
File "/home/ubuntu/.local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1250, in _execute_context
e, statement, parameters, cursor, context
File "/home/ubuntu/.local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1478, in _handle_dbapi_exception
util.reraise(*exc_info)
File "/home/ubuntu/.local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 153, in reraise
raise value
File "/home/ubuntu/.local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1246, in _execute_context
cursor, statement, parameters, context
File "/home/ubuntu/.local/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 588, in do_execute
cursor.execute(statement, parameters)
File "/home/ubuntu/.local/lib/python3.6/site-packages/mysql/connector/cursor_cext.py", line 272, in execute
self._handle_result(result)
File "/home/ubuntu/.local/lib/python3.6/site-packages/mysql/connector/cursor_cext.py", line 163, in _handle_result
self._handle_resultset()
File "/home/ubuntu/.local/lib/python3.6/site-packages/mysql/connector/cursor_cext.py", line 651, in _handle_resultset
self._rows = self._cnx.get_rows()[0]
File "/home/ubuntu/.local/lib/python3.6/site-packages/mysql/connector/connection_cext.py", line 301, in get_rows
else self._cmysql.fetch_row()
SystemError: <built-in method fetch_row of _mysql_connector.MySQL object at 0x3cdaa10> returned a result with an error set
EDIT 2
What finally did work was using mysqlclient by specifying the SQLAlchemy connection string to begin with mysql+mysqldb. I am not giving this as an answer, because the initial problem persists.
I'm on Manjaro Linux KDE and every time I try to install a module with pip it gives me this error:
Defaulting to user installation because normal site-packages is not writeable
ERROR:
Exception:
Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/pip/_internal/cli/base_command.py", line 186, in _main
status = self.run(options, args)
File "/usr/lib/python3.8/site-packages/pip/_internal/commands/install.py", line 279, in run
session = self.get_default_session(options)
File "/usr/lib/python3.8/site-packages/pip/_internal/cli/req_command.py", line 74, in get_default_session
self._session = self.enter_context(self._build_session(options))
File "/usr/lib/python3.8/site-packages/pip/_internal/cli/req_command.py", line 84, in _build_session
session = PipSession(
File "/usr/lib/python3.8/site-packages/pip/_internal/network/session.py", line 241, in __init__
self.headers["User-Agent"] = user_agent()
File "/usr/lib/python3.8/site-packages/pip/_internal/network/session.py", line 132, in user_agent
zip(["name", "version", "id"], distro.linux_distribution()),
File "/usr/lib/python3.8/site-packages/distro.py", line 122, in linux_distribution
return _distro.linux_distribution(full_distribution_name)
File "/usr/lib/python3.8/site-packages/distro.py", line 677, in linux_distribution
self.version(),
File "/usr/lib/python3.8/site-packages/distro.py", line 737, in version
self.lsb_release_attr('release'),
File "/usr/lib/python3.8/site-packages/distro.py", line 899, in lsb_release_attr
return self._lsb_release_info.get(attribute, '')
File "/usr/lib/python3.8/site-packages/distro.py", line 552, in __get__
ret = obj.__dict__[self._fname] = self._f(obj)
File "/usr/lib/python3.8/site-packages/distro.py", line 1012, in _lsb_release_info
stdout = subprocess.check_output(cmd, stderr=devnull)
File "/usr/lib/python3.8/subprocess.py", line 411, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
File "/usr/lib/python3.8/site-packages/run/__init__.py", line 145, in __new__
process = cls.create_process(command, stdin, cwd=cwd, env=env, shell=shell)
File "/usr/lib/python3.8/site-packages/run/__init__.py", line 121, in create_process
shlex.split(command),
File "/usr/lib/python3.8/shlex.py", line 311, in split
return list(lex)
File "/usr/lib/python3.8/shlex.py", line 300, in __next__
token = self.get_token()
File "/usr/lib/python3.8/shlex.py", line 109, in get_token
raw = self.read_token()
File "/usr/lib/python3.8/shlex.py", line 140, in read_token
nextchar = self.instream.read(1)
AttributeError: 'tuple' object has no attribute 'read'
Traceback (most recent call last):
File "/usr/bin/pip3", line 11, in <module>
load_entry_point('pip==20.0.2', 'console_scripts', 'pip3')()
File "/usr/lib/python3.8/site-packages/pip/_internal/cli/main.py", line 75, in main
return command.main(cmd_args)
File "/usr/lib/python3.8/site-packages/pip/_internal/cli/base_command.py", line 105, in main
return self._main(args)
File "/usr/lib/python3.8/site-packages/pip/_internal/cli/base_command.py", line 224, in _main
self.handle_pip_version_check(options)
File "/usr/lib/python3.8/site-packages/pip/_internal/cli/req_command.py", line 143, in handle_pip_version_check
session = self._build_session(
File "/usr/lib/python3.8/site-packages/pip/_internal/cli/req_command.py", line 84, in _build_session
session = PipSession(
File "/usr/lib/python3.8/site-packages/pip/_internal/network/session.py", line 241, in __init__
self.headers["User-Agent"] = user_agent()
File "/usr/lib/python3.8/site-packages/pip/_internal/network/session.py", line 132, in user_agent
zip(["name", "version", "id"], distro.linux_distribution()),
File "/usr/lib/python3.8/site-packages/distro.py", line 122, in linux_distribution
return _distro.linux_distribution(full_distribution_name)
File "/usr/lib/python3.8/site-packages/distro.py", line 677, in linux_distribution
self.version(),
File "/usr/lib/python3.8/site-packages/distro.py", line 737, in version
self.lsb_release_attr('release'),
File "/usr/lib/python3.8/site-packages/distro.py", line 899, in lsb_release_attr
return self._lsb_release_info.get(attribute, '')
File "/usr/lib/python3.8/site-packages/distro.py", line 552, in __get__
ret = obj.__dict__[self._fname] = self._f(obj)
File "/usr/lib/python3.8/site-packages/distro.py", line 1012, in _lsb_release_info
stdout = subprocess.check_output(cmd, stderr=devnull)
File "/usr/lib/python3.8/subprocess.py", line 411, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
File "/usr/lib/python3.8/site-packages/run/__init__.py", line 145, in __new__
process = cls.create_process(command, stdin, cwd=cwd, env=env, shell=shell)
File "/usr/lib/python3.8/site-packages/run/__init__.py", line 121, in create_process
shlex.split(command),
File "/usr/lib/python3.8/shlex.py", line 311, in split
return list(lex)
File "/usr/lib/python3.8/shlex.py", line 300, in __next__
token = self.get_token()
File "/usr/lib/python3.8/shlex.py", line 109, in get_token
raw = self.read_token()
File "/usr/lib/python3.8/shlex.py", line 140, in read_token
nextchar = self.instream.read(1)
AttributeError: 'tuple' object has no attribute 'read'
Also, when I try to run a program where I imported selenium or any other installed module from pip it gives me the same error.
This is my pip version: pip 20.0.2 from /usr/lib/python3.8/site-packages/pip (python 3.8)
Thank you all in advance!
I am trying to do pip3 install caffe, but I am getting this on Ubuntu x64 machine:
Exception:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/usr/lib/python3/dist-packages/pip/commands/install.py", line 353, in run
wb.build(autobuilding=True)
File "/usr/lib/python3/dist-packages/pip/wheel.py", line 749, in build
self.requirement_set.prepare_files(self.finder)
File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 380, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 554, in _prepare_file
require_hashes
File "/usr/lib/python3/dist-packages/pip/req/req_install.py", line 278, in populate_link
self.link = finder.find_requirement(self, upgrade)
File "/usr/lib/python3/dist-packages/pip/index.py", line 465, in find_requirement
all_candidates = self.find_all_candidates(req.name)
File "/usr/lib/python3/dist-packages/pip/index.py", line 423, in find_all_candidates
for page in self._get_pages(url_locations, project_name):
File "/usr/lib/python3/dist-packages/pip/index.py", line 568, in _get_pages
page = self._get_page(location)
File "/usr/lib/python3/dist-packages/pip/index.py", line 683, in _get_page
return HTMLPage.get_page(link, session=self.session)
File "/usr/lib/python3/dist-packages/pip/index.py", line 795, in get_page
resp.raise_for_status()
File "/usr/share/python-wheels/requests-2.18.4-py2.py3-none-any.whl/requests/models.py", line 935, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://pypi.org/simple/caffe/
stiv#gaidar:~/lpr$
how can I fix it
Caffe should be installed on Ubuntu/Debian via apt-get install cafe-cpu or apt-get install cafe-gpu.
I have a python app the connects to AWS RDS.
The connection string allows me to run the app in a Docker with no issues:
postgresql://<usr>:<pwd>#<svr>/<db>
The following 2 connection strings runs with the error below:
postgresql://<usr>:<pwd>#<svr>/<db>?sslmode=verify-full&sslrootcert=xxx
postgresql://<usr>:<pwd>#<svr>/<db>?sslmode=require
Error (the bottom snippet):
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2309, in __call__
return self.wsgi_app(environ, start_response)
File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2295, in wsgi_app
response = self.handle_exception(e)
File "/usr/local/lib/python3.7/site-packages/flask_restful/__init__.py", line 269, in error_router
return original_handler(e)
File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1741, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.7/site-packages/flask/_compat.py", line 34, in reraise
raise value.with_traceback(tb)
File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2292, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1815, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python3.7/site-packages/flask_restful/__init__.py", line 269, in error_router
return original_handler(e)
File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1718, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.7/site-packages/flask/_compat.py", line 34, in reraise
raise value.with_traceback(tb)
File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1813, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1799, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/usr/local/lib/python3.7/site-packages/flask_restful/__init__.py", line 458, in wrapper
resp = resource(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/flask/views.py", line 88, in view
return self.dispatch_request(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/flask_restful/__init__.py", line 573, in dispatch_request
resp = meth(*args, **kwargs)
File "./database/database.py", line 29, in post
database.save()
File "./database/database.py", line 35, in save
db.session.commit()
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/scoping.py", line 162, in do
return getattr(self.registry(), name)(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 1026, in commit
self.transaction.commit()
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 493, in commit
self._prepare_impl()
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 472, in _prepare_impl
self.session.flush()
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 2451, in flush
self._flush(objects)
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 2589, in _flush
transaction.rollback(_capture_exception=True)
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py", line 68, in __exit__
compat.reraise(exc_type, exc_value, exc_tb)
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 129, in reraise
raise value
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 2549, in _flush
flush_context.execute()
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/unitofwork.py", line 422, in execute
rec.execute(self)
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/unitofwork.py", line 589, in execute
uow,
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/persistence.py", line 213, in save_obj
) in _organize_states_for_save(base_mapper, states, uowtransaction):
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/persistence.py", line 374, in _organize_states_for_save
base_mapper, uowtransaction, states
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/persistence.py", line 1585, in _connections_for_states
connection = uowtransaction.transaction.connection(base_mapper)
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 312, in connection
return self._connection_for_bind(bind, execution_options)
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 418, in _connection_for_bind
conn = self._parent._connection_for_bind(bind, execution_options)
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 430, in _connection_for_bind
conn = bind._contextual_connect()
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 2226, in _contextual_connect
self._wrap_pool_connect(self.pool.connect, None),
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 2266, in _wrap_pool_connect
e, dialect, self
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1536, in _handle_dbapi_exception_noconnection
util.raise_from_cause(sqlalchemy_exception, exc_info)
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 383, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=cause)
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 128, in reraise
raise value.with_traceback(tb)
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 2262, in _wrap_pool_connect
return fn()
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/pool/base.py", line 354, in connect
return _ConnectionFairy._checkout(self)
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/pool/base.py", line 751, in _checkout
fairy = _ConnectionRecord.checkout(pool)
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/pool/base.py", line 483, in checkout
rec = pool._do_get()
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/pool/impl.py", line 138, in _do_get
self._dec_overflow()
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py", line 68, in __exit__
compat.reraise(exc_type, exc_value, exc_tb)
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 129, in reraise
raise value
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/pool/impl.py", line 135, in _do_get
return self._create_connection()
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/pool/base.py", line 299, in _create_connection
return _ConnectionRecord(self)
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/pool/base.py", line 428, in __init__
self.__connect(first_connect_check=True)
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/pool/base.py", line 630, in __connect
connection = pool._invoke_creator(self)
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/strategies.py", line 114, in connect
return dialect.connect(*cargs, **cparams)
File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 453, in connect
return self.dbapi.connect(*cargs, **cparams)
File "/usr/local/lib/python3.7/site-packages/psycopg2/__init__.py", line 130, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) could not create SSL context: library has no ciphers
When I run with all 3 connection types, it works on all machines except Docker. Is there a reason why this is happening only in a Docker?
I forgot to state, I'm using SQLAlchemy to connect to postgresql.
Thank you.
My Dockerfile:
FROM python:3.7.2-stretch
COPY . /
RUN pip install -r requirements.txt
EXPOSE 5000
WORKDIR /models
CMD ["uwsgi", "--ini", "uwsgi.ini"]
My docker-compose
version: '3.1'
services:
modelling:
build:
context: ./modelling
image: users-api
container_name: modelling
ports:
- 5000:5000
restart: always
My requirements:
aniso8601==6.0.0
argon2-cffi==19.1.0
atomicwrites==1.3.0
attrs==19.1.0
cffi==1.12.2
Click==7.0
Flask==1.0.2
Flask-JWT-Extended==3.18.0
Flask-RESTful==0.3.7
Flask-SQLAlchemy==2.3.2
itsdangerous==1.1.0
Jinja2==2.10
MarkupSafe==1.1.1
more-itertools==7.0.0
pluggy==0.9.0
psycopg2-binary==2.7.7
py==1.8.0
pycparser==2.19
PyJWT==1.7.1
pytest==4.3.1
pytz==2018.9
six==1.12.0
SQLAlchemy==1.3.1
uWSGI==2.0.18
Werkzeug==0.15.1
Try to change following string in your requirements.txt:
psycopg2-binary==2.7.7
to
psycopg2==2.7.7 --no-binary :all: