zope.interface.registry ImportError for Pyramid on Travis - pyramid

I'm having trouble working with Pyramid on travis; the zope.interfaces dependency doesn't work.
This has to be in system python or --system-site-packages because I'm using binary scientific packages (scipy).
File "/usr/local/lib/python2.7/dist-packages/pyramid/config/__init__.py", line 20, in <module>
from pyramid.authorization import ACLAuthorizationPolicy
File "/usr/local/lib/python2.7/dist-packages/pyramid/authorization.py", line 9, in <module>
from pyramid.security import (
File "/usr/local/lib/python2.7/dist-packages/pyramid/security.py", line 13, in <module>
from pyramid.threadlocal import get_current_registry
File "/usr/local/lib/python2.7/dist-packages/pyramid/threadlocal.py", line 3, in <module>
from pyramid.registry import global_registry
File "/usr/local/lib/python2.7/dist-packages/pyramid/registry.py", line 5, in <module>
from zope.interface.registry import Components
ImportError: No module named registry
This is my current travis.yml:
language: c
install:
- sudo apt-get install python-scipy python-pip
- sudo pip install -r requirements.txt
- sudo pip install .
script:
- nosetests
after_success:
- coveralls
The build log indicates that zope.interface-4.1.2 has been installed.

Related

ModuleNotFoundError: No module named 'six' | python =3.10 | six is already installed [duplicate]

This question already has answers here:
Python module not found in virtualenv
(2 answers)
Module installed with PIP in virtualenv not found
(3 answers)
Closed last month.
I am getting below "No module named 'six'" , but it is already installed
sudo virtualenv ve
Traceback (most recent call last):
File "/usr/bin/virtualenv", line 5, in <module>
from virtualenv.__main__ import run_with_catch
File "/usr/lib/python3/dist-packages/virtualenv/__init__.py", line 3, in <module>
from .run import cli_run, session_via_cli
File "/usr/lib/python3/dist-packages/virtualenv/run/__init__.py", line 7, in <module>
from ..app_data import make_app_data
File "/usr/lib/python3/dist-packages/virtualenv/app_data/__init__.py", line 11, in <module>
from .na import AppDataDisabled
File "/usr/lib/python3/dist-packages/virtualenv/app_data/na.py", line 5, in <module>
from .base import AppData, ContentStore
File "/usr/lib/python3/dist-packages/virtualenv/app_data/base.py", line 9, in <module>
import six
ModuleNotFoundError: No module named 'six'
python -c "import six; print (six.__version__)"
1.16.0
Already tried steps (didn't work)
sudo apt-get remove python3-virtualenv
sudo apt-get install python3-virtualenv
pip3 uninstall six
pip3 install six
sudo virtualenv ve (throws error)
pip3 install urllib3 --upgrade
version:
python 3.10
six 1.16

libcrypto not found using oscrypto library in Alpine-based Docker image

I am getting exactly the same error as mentioned in ->
The library libcrypto could not be found
I understood the issue, however, I could not figure out the resolution. Do I need to update my lambda configuration or do I need to upgrade my Python libraries?
PFB my requriements.txt files
cryptography==36.0.2
botocore==1.20.0
azure-storage-blob==2.1.0
azure-storage-common==2.1.0
boto3==1.17.0
asn1crypto==1.5.1
certifi==2022.9.14
cffi==1.15.1
charset-normalizer==2.1.1
filelock==3.8.0
idna==3.4
oscrypto==1.3.0
pycparser==2.21
pycryptodomex==3.15.0
PyJWT==2.5.0
pyOpenSSL==22.0.0
pytz==2022.2.1
requests==2.28.1
typing_extensions==4.3.0
urllib3==1.26.12
My docker file -
FROM python:3.9-alpine3.16
COPY requirements.txt requirements.txt
RUN apk --update --no-cache add --virtual build-dependencies gcc python3-dev musl-dev libc-dev linux-headers libxslt-dev libxml2-dev py-pip ca-certificates wget libffi-dev openssl-dev python3-dev expat==2.4.9-r0 py-pip build-base zlib zlib-dev libressl libressl-dev \
&& apk add python3 make g++ \
&& pip install --upgrade pip \
&& pip install --upgrade pip setuptools \
&& pip install -r requirements.txt \
&& apk del build-dependencies
RUN pip install snowflake-connector-python==2.8.0 --no-use-pep517
RUN python -c 'from oscrypto import asymmetric'
Attempting docker build with the Dockerfile above results in a failure with:
Step 4/4 : RUN python -c 'from oscrypto import asymmetric'
---> Running in dc8f8b8920ac
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/lib/python3.9/site-packages/oscrypto/asymmetric.py", line 19, in <module>
from ._asymmetric import _unwrap_private_key_info
File "/usr/local/lib/python3.9/site-packages/oscrypto/_asymmetric.py", line 27, in <module>
from .kdf import pbkdf1, pbkdf2, pkcs12_kdf
File "/usr/local/lib/python3.9/site-packages/oscrypto/kdf.py", line 9, in <module>
from .util import rand_bytes
File "/usr/local/lib/python3.9/site-packages/oscrypto/util.py", line 14, in <module>
from ._openssl.util import rand_bytes
File "/usr/local/lib/python3.9/site-packages/oscrypto/_openssl/util.py", line 6, in <module>
from ._libcrypto import libcrypto, libcrypto_version_info, handle_openssl_error
File "/usr/local/lib/python3.9/site-packages/oscrypto/_openssl/_libcrypto.py", line 9, in <module>
from ._libcrypto_cffi import (
File "/usr/local/lib/python3.9/site-packages/oscrypto/_openssl/_libcrypto_cffi.py", line 27, in <module>
raise LibraryNotFoundError('The library libcrypto could not be found')
oscrypto.errors.LibraryNotFoundError: The library libcrypto could not be found
The command '/bin/sh -c python -c 'from oscrypto import asymmetric'' returned a non-zero code: 1
The exception is taking place at https://github.com/wbond/oscrypto/blob/1.3.0/oscrypto/_openssl/_libcrypto_cffi.py
Tracking through oscrypto._ffi, the problem comes down to an issue opening libcrypto with the ctypes library:
>>> import ctypes.util
>>> ctypes.util.find_library('crypto')
>>>
Why? Because /usr/lib has only libcrypto.so.1.1, and not a libcrypto.so symlink pointing to it. Easily fixed by adding an extra line to your Dockerfile:
RUN ln -s libcrypto.so.1.1 /usr/lib/libcrypto.so
...after which Python's ctypes behaves:
>>> from ctypes.util import find_library
>>> find_library('crypto')
'libcrypto.so.1.1'
...and so does oscrypto:
>>> from oscrypto import asymmetric
>>>

Unable to install and use pyinstaller inside of github actions

I am trying to install pyinstaller inside of my github actions workflow.
Using pip install pyinstaller was fine on ubuntu-latest but on windows-latest it was not however. It returns the following log.
Requirement already satisfied: future in c:\hostedtoolcache\windows\python\3.9.12\x64\lib\site-packages (from pefile>=2017.8.1->pyinstaller) (0.18.2)
Using legacy 'setup.py install' for pefile, since package 'wheel' is not installed.
Installing collected packages: pywin32-ctypes, altgraph, pyinstaller-hooks-contrib, pefile, pyinstaller
Running setup.py install for pefile: started
ERROR: Operation cancelled by user
Running setup.py install for pefile: finished with status 'canceled'
Error: The operation was canceled.
build:
name: Build Executables
needs: create_release
runs-on: ${{ matrix.config.os }}
strategy:
matrix:
config:
- os: ubuntu-latest
- os: macos-latest
- os: windows-latest
steps:
- uses: actions/checkout#v3
- name: Setup Python
uses: actions/setup-python#v3
with:
python-version: '3.9.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pyinstaller
- name: Build with pyinstaller for ${{ matrix.config.os }}
run: pyinstaller game.spec
Direct link to github action file: https://github.com/daanbreur/SwishandFrick/blob/main/.github/workflows/build.yml
Trying to install the missing dependencies manually doesnt resolve the issue however
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel setuptools
pip install -r requirements.txt
pip install pywin32 pefile pyinstaller
Direct link to github action file: https://github.com/daanbreur/SwishandFrick/blob/main/.github/workflows/build.yml
ubuntu-latest fails to locate the pywin32 package
Installing collected packages: PyTMX, pygame, future, pyscroll
Successfully installed PyTMX-3.31 future-0.18.2 pygame-2.1.2 pyscroll-2.29
ERROR: Could not find a version that satisfies the requirement pywin32 (from versions: none)
ERROR: No matching distribution found for pywin32
Error: Process completed with exit code 1.
And windows-latest crashes entirely
Run python -m pip install --upgrade pip wheel setuptools
pip install -r requirements.txt
pip install pywin32 pefile pyinstaller
Traceback (most recent call last):
File "C:\hostedtoolcache\windows\Python\3.9.12\x64\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\hostedtoolcache\windows\Python\3.9.12\x64\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\hostedtoolcache\windows\Python\3.9.12\x64\lib\site-packages\pip\__main__.py", line 29, in <module>
from pip._internal.cli.main import main as _main
File "C:\hostedtoolcache\windows\Python\3.9.12\x64\lib\site-packages\pip\_internal\cli\main.py", line 9, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "C:\hostedtoolcache\windows\Python\3.9.12\x64\lib\site-packages\pip\_internal\cli\autocompletion.py", line 10, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "C:\hostedtoolcache\windows\Python\3.9.12\x64\lib\site-packages\pip\_internal\cli\main_parser.py", line 8, in <module>
from pip._internal.cli import cmdoptions
File "C:\hostedtoolcache\windows\Python\3.9.12\x64\lib\site-packages\pip\_internal\cli\cmdoptions.py", line 23, in <module>
from pip._internal.cli.parser import ConfigOptionParser
File "C:\hostedtoolcache\windows\Python\3.9.12\x64\lib\site-packages\pip\_internal\cli\parser.py", line 12, in <module>
from pip._internal.configuration import Configuration, ConfigurationError
File "C:\hostedtoolcache\windows\Python\3.9.12\x64\lib\site-packages\pip\_internal\configuration.py", line 20, in <module>
from pip._internal.exceptions import (
File "C:\hostedtoolcache\windows\Python\3.9.12\x64\lib\site-packages\pip\_internal\exceptions.py", line 13, in <module>
from pip._vendor.requests.models import Request, Response
File "C:\hostedtoolcache\windows\Python\3.9.12\x64\lib\site-packages\pip\_vendor\requests\__init__.py", line 45, in <module>
from .exceptions import RequestsDependencyWarning
File "C:\hostedtoolcache\windows\Python\3.9.12\x64\lib\site-packages\pip\_vendor\requests\exceptions.py", line 11, in <module>
from .compat import JSONDecodeError as CompatJSONDecodeError
File "C:\hostedtoolcache\windows\Python\3.9.12\x64\lib\site-packages\pip\_vendor\requests\compat.py", line 11, in <module>
from pip._vendor import chardet
File "C:\hostedtoolcache\windows\Python\3.9.12\x64\lib\site-packages\pip\_vendor\chardet\__init__.py", line 19, in <module>
from .universaldetector import UniversalDetector
File "C:\hostedtoolcache\windows\Python\3.9.12\x64\lib\site-packages\pip\_vendor\chardet\universaldetector.py", line 46, in <module>
from .latin1prober import Latin1Prober
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 846, in exec_module
File "<frozen importlib._bootstrap_external>", line 941, in get_code
File "<frozen importlib._bootstrap_external>", line 1040, in get_data
KeyboardInterrupt
What am I missing for windows and how can I let ubuntu skip the step for windows dependencies.
Big oops on my part.
Windows didn't fail to install the dependencies, Ubuntu failed to zip the archive and that lead to it erroring.
By default github-actions is configured to automatically cancel all other jobs in the matrix. Setting fail-fast inside the strategy to false stops it from canceling other jobs. See docs: jobs.<job_id>.strategy.fail-fast
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index a00be16..34b9e82 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
## -38,6 +38,7 ## jobs:
needs: create_release
runs-on: ${{ matrix.config.os }}
strategy:
+ fail-fast: false
matrix:
config:
- os: ubuntu-latest
## -49,11 +50,11 ## jobs:
uses: actions/setup-python#v3
with:
python-version: '3.9.12'
- - name: Install dependencies
+ - name: Install dependencies for ${{ matrix.config.os }}
run: |
python -m pip install --upgrade pip wheel setuptools
pip install -r requirements.txt
- pip install pywin32 pefile pyinstaller
+ pip install pyinstaller
- name: Build with pyinstaller for ${{ matrix.config.os }}
run: pyinstaller game.spec
- name: Archive Release

Trying to install latest python3

Hi guys I am following a web document how to install the latest version of python3 from deadsnake. After the installation I need to remove the symlink from python3 and recreate it to new python3 install.
rm /usr/bin/python3
ln -s python3.10 /usr/bin/python3
But now i want to install ansible with pip3 install ansible i get this error:
File "/usr/bin/pip3", line 9, in
from pip import main File "/usr/lib/python3/dist-packages/pip/init.py", line 22, in
from pip._vendor.requests.packages.urllib3.exceptions import DependencyWarning File
"/usr/lib/python3/dist-packages/pip/_vendor/init.py", line 73, in
vendored("pkg_resources") File "/usr/lib/python3/dist-packages/pip/_vendor/init.py", line 33, in
vendored

While installing nltk package getting ModuleNotFoundError: No module named '_sqlite3'

Getting below error while running a code snippet which has nltk dependencies.
Manually installed python 3.6.5 and using it in the virtual enviornment
The OS (Red Hat Linux 7.4-Maipo) has python 2.7.4 installed in it.
Traceback (most recent call last):
File "FLASK_RECOMMENDER_VER_1_1.py", line 15, in <module>
import nltk
File "/home/ec2-user/RecommenderEngine/re_env/lib/python3.6/site-packages/nltk/__init__.py", line 137, in <module>
from nltk.stem import *
File "/home/ec2-user/RecommenderEngine/re_env/lib/python3.6/site-packages/nltk/stem/__init__.py", line 29, in <module>
from nltk.stem.snowball import SnowballStemmer
File "/home/ec2-user/RecommenderEngine/re_env/lib/python3.6/site-packages/nltk/stem/snowball.py", line 32, in <module>
from nltk.corpus import stopwords
File "/home/ec2-user/RecommenderEngine/re_env/lib/python3.6/site-packages/nltk/corpus/__init__.py", line 66, in <module>
from nltk.corpus.reader import *
File "/home/ec2-user/RecommenderEngine/re_env/lib/python3.6/site-packages/nltk/corpus/reader/__init__.py", line 105, in <module>
from nltk.corpus.reader.panlex_lite import *
File "/home/ec2-user/RecommenderEngine/re_env/lib/python3.6/site-packages/nltk/corpus/reader/panlex_lite.py", line 15, in <module>
import sqlite3
File "/usr/local/lib/python3.6/sqlite3/__init__.py", line 23, in <module>
from sqlite3.dbapi2 import *
File "/usr/local/lib/python3.6/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ModuleNotFoundError: No module named '_sqlite3'
Tried below solution but it didn't help (used yum and pip instead) :
solution 1
sudo apt-get install libsqlite3-dev
(Or you can install more packages as suggested on the pyenv wiki:
apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev xz-utils tk-dev
Now in the downloaded python source rebuild and install python with the following command: ./configure --enable-loadable-sqlite-extensions && make && sudo make install.
My Attempt throwing below error :
Collecting libsqlite3-dev
Could not find a version that satisfies the requirement libsqlite3-dev (from versions: )
No matching distribution found for libsqlite3-dev
Answering my own question.
Finally fixed the issue by Installing sqlite-devel package :
yum install sqlite-devel
and re-installing the python as follows:
sudo wget http://python.org/ftp/python/3.6.5/Python-3.6.5.tar.xz
tar xf Python-3.6.5.tar.xz
cd Python-3.6.5
sudo ./configure --prefix=/usr/local --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib"
sudo ./configure --enable-optimizations
sudo make && sudo make altinstall

Resources