树莓派搭建python环境

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了树莓派搭建python环境相关的知识,希望对你有一定的参考价值。

参考技术A 1、更新软件源,运行命令(sudo apt-get update)更新软件源
2、觉得work目录没必要创建,所以省略makedir work
3、安装wiringPi命令加上 --recursive

4、安装WiringPi-Python
树莓派搭建python环境 https://www.yahboom.com/build.html?id=4178&cid=308

树莓派 npm私有仓库verdaccio搭建

一、首先需要安装node环境

执行node -v命令检测nodejs是否安装成功,成功如图显示

二、安装python环境

检测python环境是否搭建好,在命令窗口中执行python -v,结果如图所示即成功

三、搭建私人仓库

1、安装verdaccio,使用npm 全局安装即可。

npm install –g verdaccio

2、安装完成后,直接输入verdaccio命令即可运行

注意,上图中.yaml文件是默认的配置文件,4873端口表示默认端口,使用过程中,我们可以通过修改默认的配置文件来符合我们的需求。cat /home/pi/.config/verdaccio/config.yaml
默认配置如下所示:

其中重点

# 重点 监听端口,不配置这个只能本机访问
listen: 0.0.0.0:4873

#
# This is the default config file. It allows all users to do anything,
# so don't use it on production systems.
#
# Look here for more config file examples:
# https://github.com/verdaccio/verdaccio/tree/master/conf
#

# path to a directory with all packages
# 所有包的缓存目录 可以自定义
storage: /home/pi/.local/share/verdaccio/storage
# path to a directory with plugins to include
# 插件目录
plugins: ./plugins
# 开启web服务 能够通过web访问
web:
  title: Verdaccio
  # comment out to disable gravatar support
  # gravatar: false
  # by default packages are ordercer ascendant (asc|desc)
  # sort_packages: asc
  # convert your UI to the dark side
  # darkMode: true

# translate your registry, api i18n not available yet
# i18n:
# list of the available translations https://github.com/verdaccio/ui/tree/master/i18n/translations
#   web: en-US

auth:
  htpasswd:
    file: ./htpasswd
    # Maximum amount of users allowed to register, defaults to "+inf".
    # You can set this to -1 to disable registration.
    # max_users: 1000

# a list of other known repositories we can talk to

# 公有库配置
uplinks:
  npmjs:
    url: https://registry.npmjs.org/
    agent_options:
      keepAlive: true
      maxSockets: 40
      maxFreeSockets: 10

packages:
  '@*/*':
    # scoped packages
    access: $all
    publish: $authenticated
    unpublish: $authenticated
    proxy: npmjs

  '**':
    # allow all users (including non-authenticated users) to read and
    # publish all packages
    #
    # you can specify usernames/groupnames (depending on your auth plugin)
    # and three keywords: "$all", "$anonymous", "$authenticated"
    access: $all

    # allow all known users to publish/publish packages
    # (anyone can register by default, remember?)
    publish: $authenticated
    unpublish: $authenticated

    # if package is not available locally, proxy requests to 'npmjs' registry
    proxy: npmjs

# You can specify HTTP/1.1 server keep alive timeout in seconds for incoming connections.
# A value of 0 makes the http server behave similarly to Node.js versions prior to 8.0.0, which did not have a keep-alive timeout.
# WORKAROUND: Through given configuration you can workaround following issue https://github.com/verdaccio/verdaccio/issues/301. Set to 0 in case 60 is not enough.
server:
  keepAliveTimeout: 60

middlewares:
  audit:
    enabled: true
# 重点 监听端口,不配置这个只能本机访问
listen: 0.0.0.0:4873
# log settings
logs:
  - { type: stdout, format: pretty, level: http }
  #- {type: file, path: verdaccio.log, level: info}
#experiments:
#  # support for npm token command
#  token: false
#  # support for the new v1 search endpoint, functional by incomplete read more on ticket 1732
#  search: false
#  # disable writing body size to logs, read more on ticket 1912
#  bytesin_off: false

# This affect the web and api (not developed yet)
#i18n:
#web: en-US

四、客户端如何使用

1、先安装 nrm, 命令如下:

npm install -g nrm

2.查看 nrm ls 

Windows nrm 安装完成但 throw new ERR_INVALID_ARG_TYPE(name, ‘string‘, value);

3、添加别名
演示搭建的地址为 http://192.168.1.18:4873,可以修改自己的服务器ip地址

nrm add verdaccio http://192.168.1.18:4873

4. 可以使用 nrm use xx命令,use下地址

五、当前npm服务指向

1  注册用户

npm config  set registry http://192.168.1.18:4873

2  按照提示输入userName 和 password,email,输入后就注册完成,

npm adduser --registry=http://192.168.1.18:4873

3 查看当前用户,是否是注册用户.

npm who am i

4 如已有账户进行登录

5、最后一步就是创建一个文件夹,按照npm publish 的标准格式,创建一个私有的package(进入要发布的包文件目录下),
每次发布相同名字的包注意修改版本号,否则会报版本错误

六、发布包

1 发布

npm publish

2. 成功发布了一个私有的包,就可以在其他模块里面使用npm install [package name]来安装了, 而私有npm 里面不包含的包,例如你要安装一个vue ,webpack 这样的包,找不到的话,会被代理到 npm.js 官网去下载,并且会帮你缓存在 ./storage 文件夹里面. 再次下载,就能体验飞一般的速度了,当一个小团队使用的时候效果更佳。

3 下载包

4 使用yarn上传下载包
使用npm install -g yarn命令安装yarn
创建一个yarn模板,到一个文件夹目录下,执行初始化yarn init
发布命令yarn publish
下载包 yarn add [需要下载的包名]

 

 

参考

npm私有仓库搭建
 


 

以上是关于树莓派搭建python环境的主要内容,如果未能解决你的问题,请参考以下文章

环境搭建--使用pytharm远程调试树莓派

树莓派opencv-python环境搭建最全教程(从零开始)

树莓派人脸识别------opencv-python环境搭建最全教程(从零开始)

树莓派 npm私有仓库verdaccio搭建

Python调用OpenCV实现摄像头的运动检测[树莓派版]

搭建树莓派交叉编译环境