aos-cube已经安装成功,但是还是无法运行aos指令(找不到aos)

这种情况请安装如下操作进行确认:

第一步:

可以试试重启终端或者vscode,然后再运行aos指令。如果还是不行的话,请参考第二步。

第二步:

  1. 请确认aos-cube安装在哪个目录:

win10:/d/workspace/github/AliOS-Things$ python -m site

sys.path = [
   'D:\\workspace\\github\\AliOS-Things',
   'C:\\windows\\SYSTEM32\\python27.zip',
   'C:\\Python27\\DLLs',
   'C:\\Python27\\lib',
   'C:\\Python27\\lib\\plat-win',
   'C:\\Python27\\lib\\lib-tk',
   'C:\\Python27',
   'C:\\Users\\xxxx\\AppData\\Roaming\\Python\\Python27\\site-packages',
   'C:\\Python27\\lib\\site-packages',
]
USER_BASE: 'C:\\Users\\xxxx\\AppData\\Roaming\\Python' (exists)
USER_SITE: 'C:\\Users\\xxxx\\AppData\\Roaming\\Python\\Python27\\site-packages' (exists)
ENABLE_USER_SITE: True

其中USER_BASE就是python用户安装目录,查看该用户安装目录下的Scripts中是否存在aos指令,如果存在的话,把该目录(C:\Users\chenan.xxw\AppData\Roaming\Python\Scripts)添加到Path环境变量中即可。

如果还是有问题的话,请提问题到github issues,或者可以参考使用我们提供的docker镜像

aos-cube升级到新版本无法正常工作

aos-cube升级到0.3.x版本,运行aos提示“from aos.main import main”失败,本地Python模块路径未更新,可尝试先卸载再安装:

# 首先卸载已安装的aos-cube
$ pip uninstall aos-cube

# 重新安装aos-cube
$ pip install aos-cube

linux系统上串口、usb没有权限

Linux 操作串口及 j-link 会有root权限要求,尤其在使用 AliOS Studio时候。可以复制60-openocd.rules(来自 Arduino github project)文件到 /etc/udev/rules.d 目录下,然后运行如下命令生效:

sudo udevadm control --reload-rules

或者你也可以手动对串口及 j-link 的权限做配置:

  • $ sudo usermod -a -G dialout $(whoami),添加当前用户到 dialout 组,提供直接使用串口能力。
  • $lsubs 找到 j-link 厂商ID。如:Bus 002 Device 008: ID 1366:0105 SEGGER,厂商ID为1366,新建/etc/udev/rules.d/99-stlink-v2.rules文件,在文件里面添加规则:SUBSYSTEM=="usb", ATTR{idVendor}=="1366", MODE="666", GROUP="plugdev"

配置操作串口及 j-link权限后,重启系统生效。

ModuleNotFoundError: No module named 'constant'

Create Project Fail.Traceback (most recent call last): 
File "/Users/chenyulun/.aos/python-venv/bin/aos", 
line 7, in from aos.aos import main File "/Users/chenyulun/.aos/python-venv/lib/python3.6/site-packages/aos/aos.py", 
line 26, in from .util import * File "/Users/chenyulun/.aos/python-venv/lib/python3.6/site-packages/aos/util.py", 
line 10, in from constant import * ModuleNotFoundError: No module named 'constant'

aos-cube 0.3.11之前版本只支持python2.7,当前环境如果是python3的话,运行aos-cube就会导致冲突,请更新aos-cube。

No module named SCons.Script

aos-cube version: 0.2.60
[INFO]: Target: helloworld@developerkit
[INFO]: Currently in aos_sdk_path: '/home/ljh/work/AliOS/github_branch/AliOS-Things'
SCons import failed. Unable to find engine files in:
  /usr/local/bin/../engine
  /usr/local/bin/scons-local-3.0.1
  /usr/local/bin/scons-local
  /usr/local/lib/python2.7/dist-packages/lib/scons-3.0.1
  /usr/local/lib/scons-3.0.1
  /usr/lib/scons-3.0.1
  /usr/local/lib/scons-3.0.1
  /usr/local/lib/python2.7/dist-packages/lib/python2.7/site-packages/scons-3.0.1
  /usr/local/lib/python2.7/site-packages/scons-3.0.1
  /usr/lib/python2.7/site-packages/scons-3.0.1
  /usr/local/lib/python2.7/site-packages/scons-3.0.1
  /usr/lib/scons-3.0.1
  /usr/local/lib/python2.7/dist-packages/lib/scons
  /usr/local/lib/scons
  /usr/lib/scons
  /usr/local/lib/scons
  /usr/local/lib/python2.7/dist-packages/lib/python2.7/site-packages/scons
  /usr/local/lib/python2.7/site-packages/scons
  /usr/lib/python2.7/site-packages/scons
  /usr/local/lib/python2.7/site-packages/scons
  /usr/lib/scons
Traceback (most recent call last):
  File "/usr/local/bin/scons", line 192, in <module>
    import SCons.Script
ImportError: No module named SCons.Script
[AliOS-Things] ERROR: "s" returned error code 1.
[AliOS-Things] ERROR: Command "s c o n s   - f   / h o m e / l j h / w o r k / A l i O S / g i t h u b _ b r a n c h / A l i O S - T h i n g s / u c u b e . p y   C O M M A N D = u p l o a d   A P P L I C A T I O N = h e l l o w o r l d   B O A R D = d e v e l o p e r k i t" in "/home/ljh/work/AliOS/github_branch/AliOS-Things"

请依次尝试以下方法:

  • 更新scons:pip install scons -U
  • 卸载scons然后重新安装:pip uninstall sconspip install scons

Could not install packages due to an EnvironmentError: [Errno 13] Permission denied

ubuntu系统下,非root权限用户使用pip安装python包会提示没有权限问题:

/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/__init__.py:83: RequestsDependencyWarning: Old version of cryptography ([1, 2, 3]) may cause slowdown.
  warnings.warn(warning, RequestsDependencyWarning)
Requirement already satisfied: aos-cube in /usr/local/lib/python2.7/dist-packages (0.2.59)
Requirement already satisfied: requests in /usr/local/lib/python2.7/dist-packages (from aos-cube) (2.19.1)
Collecting scons (from aos-cube)
Collecting esptool (from aos-cube)
  Downloading https://files.pythonhosted.org/packages/51/9e/1abfb18922eeab54f0e38e7d0f113f18b285048a8d9b827f56927a848ee5/esptool-2.5.1.tar.gz (75kB)
    100% |████████████████████████████████| 81kB 58kB/s
Collecting pyserial (from aos-cube)
  Using cached https://files.pythonhosted.org/packages/0d/e4/2a744dd9e3be04a0c0907414e2a01a7c88bb3915cbe3c8cc06e209f59c30/pyserial-3.4-py2.py3-none-any.whl
Requirement already satisfied: idna<2.8,>=2.5 in /usr/local/lib/python2.7/dist-packages (from requests->aos-cube) (2.7)
Requirement already satisfied: urllib3<1.24,>=1.21.1 in /usr/local/lib/python2.7/dist-packages (from requests->aos-cube) (1.23)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /usr/local/lib/python2.7/dist-packages (from requests->aos-cube) (3.0.4)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python2.7/dist-packages (from requests->aos-cube) (2018.8.13)
Collecting pyaes (from esptool->aos-cube)
Collecting ecdsa (from esptool->aos-cube)
  Using cached https://files.pythonhosted.org/packages/63/f4/73669d51825516ce8c43b816c0a6b64cd6eb71d08b99820c00792cb42222/ecdsa-0.13-py2.py3-none-any.whl
Building wheels for collected packages: esptool
  Running setup.py bdist_wheel for esptool ... done
  Stored in directory: /disk2/chenan.xxw/.cache/pip/wheels/4b/03/99/cb358131acc8e50b6fd724e39e050751464d85245c73de5ea0
Successfully built esptool
Installing collected packages: scons, pyserial, pyaes, ecdsa, esptool
Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/scons-3.0.1.dist-info'
Consider using the `--user` option or check the permissions.

请添加--user参数安装即可:

pip install --user aos-cube

fatal: unable to access 'https://gitee.com/alios-things/gcc-arm-none-eabi-osx.git/': Failed to connect to localhost port 8118: Connection refused

需要手动下载toolchain:

git clone https://gitee.com/alios-things/gcc-arm-none-eabi-osx.git gcc-arm-none-eabi
mv gcc-arm-none-eabi/main build/compiler/gcc-arm-none-eabi/OSX && rm -rf gcc-arm-none-eabi

UnicodeDecoderError:‘utf8’ codec can't decode byte xxx in position xxx

文件路径里包含中文等其它特殊字符;或者源代码文件是非ascii和utf8编码的,且包含中文等特殊字符。

需要将AliOS-Things的代码放在不包含特殊字符的路径下,并且创建工程目录时,也需要确保路径中不包含特殊字符;

对于非ascii编码和utf8编码的文件,需要使用vs code等编辑器将其转为utf8编码。同时需要更新文中包含的特殊字符,否则会显示乱码。