Hi everyone,
I installed pyenv with pyenv-virtualenv on my manjaro. Everything seems fine, installation using pyenv install “version” and pyenv virtualenv “version” “name” works as intended. Then I activate my pyenv virtualenv and I even get the name of the environment in the terminal. When I run
which python && which pip && python -V
I get:
/home/fregy/.pyenv/shims/python
/home/fregy/.pyenv/shims/pip
Python 3.10.5
Which is correct I wanted 3.10.5. But when I try to run some code, that uses for example python’s dataclesses.py I get error because it’s trying to use dataclasses.py in /usr/lib/python3.11:
/usr/lib/python3.11/dataclasses.py:1230: in dataclass
return wrap(cls)
/usr/lib/python3.11/dataclasses.py:1220: in wrap
return _process_class(cls, init, repr, eq, order, unsafe_hash,
/usr/lib/python3.11/dataclasses.py:958: in _process_class
cls_fields.append(_get_field(cls, name, type, kw_only))
/usr/lib/python3.11/dataclasses.py:815: in _get_field
raise ValueError(f'mutable default {type(f.default)} for field '
E ValueError: mutable default <class 'libs.data_models.user_model.Email'> for field email is not allowed: use default_factor
The error itself it’s not important, the problem is it’s using different version of python.
My .zshrc file:
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/shims:$PATH"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init --path)"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
I don’t know if it’s important, but I am using urxvt as my terminal. Also, when I use VSCode and I choose my pyenv env I can use the “Go to definition” function and it opens the correct file under .pyenv/versions/3.10.5/lib/python3.10/dataclasses.py.
Thank you for any help.
I tried reinstalling pyenv alongside with pyenv-virtualenv. Play around with zshrc file, but nothing worked.