设置pyenv全局版本后仍无法获取python版本

问题描述

我已经为Windows安装了pyenv-win,还从PATH环境变量中删除了普通的python路径。

然后,我使用“ pyenv install ”安装了2个版本的python(3.6.8和3.8.0)。 enter image description here

应用pyenv全局版本运行命令“ pyenv全局3.6.8 ”,当我运行“ pyenv版本”时,显示3.6.8是全局的版本。

但是当我运行“ python --version”时,什么都没有显示,因此我无法运行任何python文件。“我也同时运行了” pyenv rehash “。此外,我在PATH环境变量中还添加了/.pyenv/pyenv-win/shims和bin。

在这里我需要您的帮助。任何线索将不胜感激,谢谢。

解决方法

我认为您应该禁用一些别名(请参阅第 3 步)

这是我安装 pyenv-win 的方法,我遇到了同样的问题:

1 - 卸载 Python(键入命令 python -V 时的当前版本)

2 - 安装 pyenv-win 并将其添加到 PATH(这里有一些通过 Chocolatey 安装它的可选步骤,它将它直接添加到 PATH)

2.2 - 安装巧克力

2.3 - 在管理员 powershell 中运行:choco install pyenv-win

3-开始菜单(windows键)->管理应用程序执行别名->禁用与python相关的别名 here it's in french but it should be similar

4 - 通过 pyenv 安装所需的 Python 版本:pyenv install DESIRED VERSION NUMBER

5- 运行 pyenv rehash

6 - 将其设置为全局 pyenv global DESIRED VERSION NUMBER

7 - 您应该通过运行命令 python -V

来查看所需的版本 ,

尝试以下步骤

pyenv --version

关闭并打开然后运行

// Get the first select element.
var items = document.querySelector('#items');
// Get the second select element.
var itemsChild = document.querySelector('#itemchild');
// Create a list with all the values I could use in the second 
// select element as option tags.
var itemsChildData = [
  {
    value: 0,group: "SHOW",text: '-- Select --'
  },{
    value: 'green',group: "xxxxx",text: 'green'
  },{
    value: 'yellow',group: "xxxxxx",text: 'yellow'
  },{
    value: 'blue',text: 'blue'
  },{
    value: 'red',text: 'red'
  }
];

// Listen for the change event in the first select element.
items.addEventListener(
  'change',function(event) {
    // Get the selected value from the first select element
    var value = event.target.value;
    // Get the last letter from the selected value
    var lastLetter = value.split('').pop();
    // Filter the list of the possible options for the second 
    // select element
    var filteredOptions = itemsChildData.filter(
        function(item) {
          // If the last character is s
          if ( 's' === lastLetter ) {
            // Return true,if the value is red or 0
            return -1 !== ['red',0].indexOf( item.value );
          }

          // If the last character it is not s,return always true
          return true;
        }
    );
    
    // Get all the option tags from the second select element.
    var options = itemsChild.querySelectorAll('option');
    
    // If we found options
    if(options){
      // Itterate over the found options
      options.forEach(
        function(opt){ 
          // And remove them from the select element.
          opt.parentElement.removeChild(opt);
        }
      );
    }

    // Finally,iterate over the filtered options
    filteredOptions.forEach(
      function(newOption) {
          // Create a new option element
          var option = document.createElement('option');
          // Assign the value
          option.value = newOption.value;
          // Assign the text
          option.innerText = newOption.text;
          // Assign the data-group
          option.dataset.group = newOption.group;
          
          // And append the new option to the second select element.
          itemsChild.appendChild(option);
      }
    );
  }
);

否则,您可以打开票证here