python虚拟环境离线安装

2023-12-14 02:29:56

虚拟环境离线安装

方法2:在联网电脑上安装打包后在离线电脑上解压。

1、联网电脑操作

需要库python3.5+numpy1.16.1+h5py2.10.0+cython0.29.15+open3d-python0.3.0+pandas0.25.3+scikit-learn0.21.3+scipy1.4.1+PyYAML5.4

  • 创建虚拟环境并激活
conda create -n virenv python=3.5 pip=20.3.4
conda activate virenv
  • 安装三方库
pip install numpy==1.16.1
pip install h5py==2.10.0
pip install cython==0.29.15
pip install open3d-python==0.3.0
pip install pandas==0.25.3
pip install scikit-learn==0.21.3
pip install scipy==1.4.1
pip install PyYAML==5.4

# pip list查看已安装库
  • 打包虚拟环境
conda pack -n varenv -o varenv.tar.gz

2、离线电脑:虚拟环境安装

将varenv.tar.gz解压到anaconda/envs/下
conda activate varenv激活虚拟环境

3、遇到问题

  • fatal error C1083 无法打开包括文件 “io.h” No such file or directory
方法1:右键我的电脑——属性——高级系统设置——环境变量——系统变量(s),在PATH中添加:
C:\Program Files (x86)\Windows Kits\10\Include\<version>\ucrt

方法2:在anaconda的命令行中输入命令:conda install libpython
  • error: Unable to find vcvarsall.bat

  • TypeError: unorderable types: NoneType() >= str()

参考pycharm - Python - Can’t Install Packages: TypeError: unorderable types: NoneType() >= str() - Stack Overflow

running install
running build
running build_ext
Traceback (most recent call last):
  File "setup.py", line 20, in <module>
    cmdclass = {'build_ext': build_ext},
  File "C:\Users\JMD\.conda\envs\randlanet\lib\distutils\core.py", line 148, in setup
    dist.run_commands()
  File "C:\Users\JMD\.conda\envs\randlanet\lib\distutils\dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "C:\Users\JMD\.conda\envs\randlanet\lib\distutils\dist.py", line 974, in run_command
    cmd_obj.run()
  File "C:\Users\JMD\.conda\envs\randlanet\lib\distutils\command\install.py", line 539, in run
    self.run_command('build')
  File "C:\Users\JMD\.conda\envs\randlanet\lib\distutils\cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "C:\Users\JMD\.conda\envs\randlanet\lib\distutils\dist.py", line 974, in run_command
    cmd_obj.run()
  File "C:\Users\JMD\.conda\envs\randlanet\lib\distutils\command\build.py", line 135, in run
    self.run_command(cmd_name)
  File "C:\Users\JMD\.conda\envs\randlanet\lib\distutils\cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "C:\Users\JMD\.conda\envs\randlanet\lib\distutils\dist.py", line 974, in run_command
    cmd_obj.run()
  File "C:\Users\JMD\.conda\envs\randlanet\lib\site-packages\Cython\Distutils\old_build_ext.py", line 186, in run
    _build_ext.build_ext.run(self)
  File "C:\Users\JMD\.conda\envs\randlanet\lib\distutils\command\build_ext.py", line 308, in run
    force=self.force)
  File "C:\Users\JMD\.conda\envs\randlanet\lib\distutils\ccompiler.py", line 1031, in new_compiler
    return klass(None, dry_run, force)
  File "C:\Users\JMD\.conda\envs\randlanet\lib\distutils\cygwinccompiler.py", line 285, in __init__
    CygwinCCompiler.__init__ (self, verbose, dry_run, force)
  File "C:\Users\JMD\.conda\envs\randlanet\lib\distutils\cygwinccompiler.py", line 129, in __init__
    if self.ld_version >= "2.10.90":
TypeError: unorderable types: NoneType() >= str()

解决:conda install mingw

  • LINK : fatal error LNK1158: 无法运行“rc.exe”

    原因是link.exe文件无法找到rc.exe和rcdll.dll文件
    
    解决方法:
    1.找到rc.exe和rcdll.dll文件,在你对应的SDK版本文件夹下
    如C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x86
    
    2.找到运行的link.exe文件所在目录
    C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\bin\Hostx86\x64
    
    3、将rc.exe和rcdll.dll文件直接复制到link.exe文件所在目录
    再次运行python setup.py 
    

文章来源:https://blog.csdn.net/qq_37935909/article/details/134879095
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。