Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update pip and conda requirements to fix error on install #328

Closed
wants to merge 4 commits into from

Conversation

lmerchant
Copy link
Collaborator

Fix error that occurs while running the microsetta-interface server after a fresh install of the repo

Reproduce the error by installing microsetta-interface following the README.md install instructions

After the microsetta-interface is installed in editable mode

$ pip install -e .

Run the Test server

$ python microsetta_interface/server.py

Error message occurs after running microsetta-interface server command

Traceback (most recent call last):
File "microsetta_interface/server.py", line 12, in
from microsetta_interface.implementation import session_locale
File "/Users/lmerchant/CMI_Work/repos_duplicate/microsetta-interface/microsetta_interface/implementation.py", line 32, in
from microsetta_interface.redis_cache import RedisCache
File "/Users/lmerchant/CMI_Work/repos_duplicate/microsetta-interface/microsetta_interface/redis_cache.py", line 2, in
import redis
File "/usr/local/anaconda3/envs/microsetta-interface/lib/python3.7/site-packages/redis/init.py", line 3, in
from redis import asyncio # noqa
File "/usr/local/anaconda3/envs/microsetta-interface/lib/python3.7/site-packages/redis/asyncio/init.py", line 1, in
from redis.asyncio.client import Redis, StrictRedis
File "/usr/local/anaconda3/envs/microsetta-interface/lib/python3.7/site-packages/redis/asyncio/client.py", line 27, in
from redis._parsers.helpers import (
File "/usr/local/anaconda3/envs/microsetta-interface/lib/python3.7/site-packages/redis/_parsers/init.py", line 1, in
from .base import BaseParser, _AsyncRESPBase
File "/usr/local/anaconda3/envs/microsetta-interface/lib/python3.7/site-packages/redis/_parsers/base.py", line 9, in
from async_timeout import timeout as async_timeout
File "/usr/local/anaconda3/envs/microsetta-interface/lib/python3.7/site-packages/async_timeout/init.py", line 5, in
from typing import Optional, Type, final
ImportError: cannot import name 'final' from 'typing' (/usr/local/anaconda3/envs/microsetta-interface/lib/python3.7/typing.py)

Look at ImportError about 'typing'

ImportError: cannot import name 'final' from 'typing' (/usr/local/anaconda3/envs/microsetta-interface/lib/python3.7/typing.py)

The error encountered occurs because the final feature was introduced in Python 3.8 and is not available in Python 3.7.

The error occurs in async_timeout

Get the version of async_timeout
$ pip show async-timeout

Name: async-timeout

Version: 5.0.0

Required-by: redis

Get the version of redis
$ pip show redis

Name: redis

Version: 5.0.7

Go to pypi page for redis: https://pypi.org/project/redis/

**Note: ** redis-py 5.0 will be the last version of redis-py to support Python 3.7, as it has reached end of life. redis-py 5.1 will support Python 3.8+.

Try installing redis-py 5.0 and not 5.0.7 and run start server command

$ pip uninstall redis
$ pip install redis==5.0.0

Still get the errors

Fix for no errors

Install redis 4.6.0

$ pip uninstall redis
$ pip install redis==4.6.0

Run the Test server

$ python microsetta_interface/server.py

Now there is no error, and the server starts

Find the versions of packages to update the original pip requirements

List the updated pip installed packages

$ pip list

Include redis==4.6.0 in pip requirements since it is not found with conda (get a PackagesNotFoundError)

openapi-spec-validator==0.2.9

swagger-ui-bundle==0.0.9

connexion[swagger-ui]==2.7.0

pyjwt[crypto]==2.1.0

pytest==5.3.3

pytest-cov==4.1.0

coveralls==3.3.1

pycountry==22.3.5

python-dateutil==2.9.0

redis==4.6.0

Save these packages and versions to the file pip_requirements_updated.txt

List the updated conda installed packages

$ conda list

Find the versions of packages to update the previous conda requirements. Note redis is removed from the conda requirements

flake8==5.0.4
flask==2.2.5
natsort==8.4.0
pycryptodome==3.15.0
pytest==5.3.3
flask-babel=2.0.0
pandas==1.3.5

Save these packages and versions to file conda_requirements_updated.txt

Delete the conda environment microsetta-interface and create it using the updated requirements

$ conda deactivate
$ conda remove -n microsetta-interface --all

$ conda create --yes -n microsetta-interface python=3.7
$ conda install --yes -n microsetta-interface --file ci/conda_requirements_updated.txt
$ conda activate microsetta-interface

Install updated pip requirements

$ pip install -r ci/pip_requirements_updated.txt

Then install the microsetta-interface in editable mode:

$ pip install -e .

Get an error after this command

ModuleNotFoundError: No module named 'babel'

Fix is to install babel

$ conda install babel

Get the version of babel with conda list

babel==2.14.0

Add babel==2.14.0 to conda_requirements_updated.txt

Update flask-babel=2.0.0 in conda_requirements_updated.txt to flask-babel==2.0.0

Remove pytest==5.3.3 from conda_requirements_updated.txt since it is already in pip_requirements_updated.txt

Delete the conda environment and recreate it using the updated requirements

Follow the steps above for deleting the environment, installing packages, and installing code

Run the Test server

$ python microsetta_interface/server.py

Now it works

Running pytest also works

Replace old requirements content with the updated content

Copy contents of updated requirements into their respective files: pip_requirements.txt and conda_requirements.txt

…ter repo install

After installing the code in the repo according to steps in the README.md file, an error
occurs when running the server with the command $ python microsetta_interface/server.py

Error: ImportError: cannot import name 'final' from 'typing'
(/usr/local/anaconda3/envs/microsetta-interface_test/lib/python3.7/typing.py)
The error encountered occurs because the final feature was introduced in Python 3.8 and
is not available in Python 3.7. The error occurs in async_timeout which
depends on redis. The version of redis installed is 5.0.7. On the pypi page for redis,
at https://pypi.org/project/redis/, this statement is found:
** Note: ** redis-py 5.0 will be the last version of redis-py to support Python 3.7,
as it has reached end of life. redis-py 5.1 will support Python 3.8+.
Uninstalling redis and installing redis==4.6.0 fixes the error when starting the server.

Used pip list and conda list to update the versions in pip_requirements.txt and
conda_requirements.txt. Keeping the same packages in each requirement file with the
updated versions resulted in an error with a fresh install and running the server.

To fix the error, removed redis==4.6.0 from conda_requirements.txt because conda could
not find this version of redis and put it in the pip_requirements.txt file. Also needed
to add babel as a package to conda_requirements.xt since there was a
ModuleNotFoundError for babel. Update flask-babel=2.0.0 in conda_requirements.txt to
flask-babel==2.0.0 replace a single = to a double =. Remove pytest==5.3.3 from
conda_requirements.txt since it is already in pip_requirements.txt.
Copy link
Collaborator

@cassidysymons cassidysymons left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please adjust this to only pin the version of redis based on your discovery of the incompatibility with a newer version. Changing versions of other packages has potentially deleterious consequences.

Pin only the redis package. Set the version to 4.6.0 in pip_requirements.txt to fix error
when running the server after an install

Remove redis from conda_requirements.txt and place in pip_requirements.txt because conda
can't locate the redis version 4.6.0.

Remove pytest from conda_requirements.txt because it was not versioned and there is a
versioned pytest < 5.3.4 in pip_requirements.txt.

Add an equal sign to "flask-babel=2.0.0" in conda_requirements.txt to set the version
using double equal signs.
@lmerchant
Copy link
Collaborator Author

conda currently has redis-server and not redis

redis-server is new for about the past 3 years on conda-forge
redis was last updated about 3 years ago on conda-forge

redis exists via pip

the pip redis version 4.6.0 is dated 6/25/2023

search for redis-server and redis versions on conda-forge

conda search redis-server --channel conda-forge

Loading channels: done

Name Version Build Channel
redis-server 6.2.5 h05f672f_1 conda-forge
redis-server 6.2.5 h80fc002_1 conda-forge
redis-server 6.2.6 h05f672f_0 conda-forge
redis-server 6.2.6 h80fc002_0 conda-forge
redis-server 7.0.0 h25ffcba_0 conda-forge
redis-server 7.0.0 h3fcc8fb_0 conda-forge
redis-server 7.0.4 h54dc03d_0 conda-forge
redis-server 7.0.4 hc68d04a_0 conda-forge
redis-server 7.0.8 hc68d04a_0 conda-forge
redis-server 7.0.9 hc68d04a_0 conda-forge
redis-server 7.0.10 hc68d04a_0 conda-forge
redis-server 7.0.11 hc68d04a_0 conda-forge
redis-server 7.0.12 h2f7af46_0 conda-forge
redis-server 7.2.0 h2f7af46_0 conda-forge
redis-server 7.2.1 h2f7af46_0 conda-forge
redis-server 7.2.2 h6916386_0 conda-forge
redis-server 7.2.3 h6916386_0 conda-forge
redis-server 7.2.4 h6916386_0 conda-forge
redis-server 7.2.5 h2d65c12_0 conda-forge
redis-server 7.4.0 h2d65c12_0 conda-forge

newest version of 7.4.0 and oldest version of redis-server 6.2.5 give an error when running microsetta-interface server

conda search redis --channel conda-forge

redis 3.5.3 pyhd3eb1b0_0 pkgs/main
redis 4.0.2 hc28a91c_0 pkgs/main
redis 4.0.8 h1de35cc_0 pkgs/main
redis 4.0.9 h1de35cc_0 pkgs/main
redis 4.0.10 h1de35cc_0 pkgs/main
redis 4.0.11 h1de35cc_0 pkgs/main
redis 5.0.0 h1de35cc_0 pkgs/main
redis 5.0.3 h1de35cc_0 pkgs/main

both redis and redis-server versions from conda-forge failed

with error
ImportError: cannot import name 'final' from 'typing' (/usr/local/anaconda3/envs/microsetta-interface/lib/python3.7/typing.py)

But if install redis via pip with version 4.6.0,

the microsetta-interface server runs without an error

but redis-server wasn't installed via conda or pip. It exists because of a mac install.

To install redis-server via pip, install version 6.0.9 (10/30/2020), the most recent version on pip

@lmerchant lmerchant closed this by deleting the head repository Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants