Code Monkey home page Code Monkey logo

Comments (2)

Forgo7ten avatar Forgo7ten commented on June 30, 2024 1

I found this was caused by PROMPT_COMMAND or precmd_functions registered by the pyenv-virtualenv-init script.
I can fix this by removing eval "$(pyenv virtualenv-init -)" in bashrc, but this leaves me without a virtualenv prompt.

By inserting the following command on line 133 of this script, you can solve the problem that the environment variable cannot be written.

    local ret=\$?
+   _OLD_VIRTUAL_PATH="\$PATH"
    if [ -n "\${VIRTUAL_ENV-}" ]; then

However, bash's PS1 environment variables, such as display (venv) may require more code modifications.
I'm not very familiar with these, so I just added _OLD_VIRTUAL_PS1="\$PS1" in the same position as above.
The effect of this will be a bit funny, it will become the prefix of (py38) (venv) (py38), even after executing the venv/bin/activate script multiple times, it will become (py38) (venv ) (venv) (venv) (py38). But at least it works.

I don't have much energy to get familiar with the code, so let it be.
I still hope you can fix this problem, thank you again.

from pyenv-virtualenv.

Forgo7ten avatar Forgo7ten commented on June 30, 2024

To add, this happens not only when the virtual environment is set to global. As long as the virtual environment (including local) is set, it cannot be set again.
I can understand that this feature cannot be set again after local setting. But I am used to setting a virtual environment globally (clean) instead of a specified version, which results in me being unable to activate the virtual environment in a certain folder again.
...
I tested the pyenv local and pyenv global settings respectively. For a specific version, it will not affect the use of my venv; but if a virtual environment is activated, I cannot activate a local environment.
After executing the ./venv/bin/activate script, I checked the PATH environment variable and found that there was no path to the current venv. This happens only when pyenv-virtualenv is activated.

from pyenv-virtualenv.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.