简体   繁体   English

升级到 python3 后 Mac M1 python 包错误

[英]Mac M1 python packages error after upgrade to python3

I am writing a project in NativeScript and I received the following error the last few days when I tried the commands: ns run ios or ns doctor .我正在 NativeScript 中编写一个项目,最近几天我尝试这些命令时收到以下错误: ns run iosns doctor

Couldn't retrieve installed python packages.无法检索已安装的 python 包。

The Python 'six' package not found. Python '六' package 未找到。

在此处输入图像描述

I tried python and pip upgrade and also the command pip install six .我尝试了 python 和 pip 升级以及命令pip install six Nothing of them fixed the problem.他们都没有解决问题。

I believe that is not a NativeScript issue, is about the configuration of the python packages in my machine.我相信这不是 NativeScript 问题,而是关于我机器中 python 包的配置。 I mention that I am using a MacBook with M1 chip and it is running the 12.5 OS version.我提到我使用的是带有 M1 芯片的 MacBook,它运行的是 12.5 操作系统版本。

I will appreciate any suggestions on this situation.对于这种情况的任何建议,我将不胜感激。

Lastly, I found the solution.最后,我找到了解决方案。 It was about the python folder into the path /usr/local/bin/python就是把python这个文件夹放到路径/usr/local/bin/python

You could check it by the following command: where python您可以通过以下命令查看它: where python

In my case this folder is missing, perhaps I deleted it after the upgrade of the python3.在我的例子中,这个文件夹丢失了,也许我在升级 python3 后删除了它。

That was a mistake both folders should exist on this path!这是一个错误,两个文件夹都应该存在于这条路径上!

If you type: where python you should receive: /usr/local/bin/python如果你输入: where python你应该收到:/usr/local/bin/python

If you type: where python3 you should receive: /usr/local/bin/python3如果你输入: where python3你应该收到:/usr/local/bin/python3

In order to fix the error, I installed python again by using the brew install pyenv this suggestion helps me to install it properly.为了修复错误,我使用brew install pyenv 这个建议帮助我正确安装它。

In the end, in order to eliminate all errors I installed the Python six package by using the command: pip install --ignore-installed six最后,为了消除所有错误,我使用以下命令安装了 Python 6 package: pip install --ignore-installed six

Try doing it with the python virtual environment.尝试使用 python 虚拟环境执行此操作。 Following are the steps.以下是步骤。

  1. Create a virtual environment.创建一个虚拟环境。
  2. Activate the virtual environment.激活虚拟环境。
  3. Run the pip install command with the virtual environment active.在虚拟环境处于活动状态的情况下运行 pip 安装命令。

Implement as follows:实现如下:

  • use correct version of Python when creating VENV创建 VENV 时使用正确版本的 Python

python3 -m venv venv

  • activate on Unix or MacOS在 Unix 或 MacOS 上激活

source venv/bin/activate

  • activate on Windows (cmd.exe)在 Windows (cmd.exe) 上激活

venv\Scripts\activate.bat

  • activate on Windows (PowerShell)在 Windows (PowerShell) 上激活

'venv\Scripts\Activate.ps1' 'venv\Scripts\Activate.ps1'

  • install the required package in the virtual environment在虚拟环境中安装需要的package

python3 -m pip install --upgrade pip

python3 -m pip install six

Note: This works only when you are in the virtual environment.注意:这仅在您处于虚拟环境中时有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM