D:.net project\pythonProject\爬虫\控制windows系统>set CONDA_FORCE_32BIT=1

D:.net project\pythonProject\爬虫\控制windows系统>conda install pyaudio

CondaValueError: cannot use CONDA_FORCE_32BIT=1 in base env

D:.net project\pythonProject\爬虫\控制windows系统>conda info

 active environment : None
  user config file : C:\Users\24497\.condarc

populated config files : conda version : 4.8.3 conda-build version : 3.10.5 python version : 3.6.10.final.0 virtual packages : base environment : D:\soft\Anaconda (writable) channel URLs : https://repo.anaconda.com/pkgs/main/win-32 https://repo.anaconda.com/pkgs/main/noarch https://repo.anaconda.com/pkgs/r/win-32 https://repo.anaconda.com/pkgs/r/noarch https://repo.anaconda.com/pkgs/msys2/win-32 https://repo.anaconda.com/pkgs/msys2/noarch package cache : D:\soft\Anaconda\pkgs32 C:\Users\24497.conda\pkgs32 C:\Users\24497\AppData\Local\conda\conda\pkgs32 envs directories : D:\soft\Anaconda\envs C:\Users\24497.conda\envs C:\Users\24497\AppData\Local\conda\conda\envs platform : win-32 user-agent : conda/4.8.3 requests/2.18.4 CPython/3.6.10 Windows/10 Windows/10.0.18362 administrator : False netrc file : None offline mode : False

D:.net project\pythonProject\爬虫\控制windows系统>conda create -n env_name python=3.6 Collecting package metadata (repodata.json): done Solving environment: done

Package Plan

environment location: D:\soft\Anaconda\envs\env_name

added / updated specs: - python=3.6

The following packages will be downloaded:

package                    |            build
---------------------------|-----------------
certifi-2020.6.20         |           py36_0         160 KB
pip-20.1.1                 |           py36_1         2.1 MB
python-3.6.10             |       h9f7ef89_2       19.5 MB
setuptools-47.3.1         |           py36_0         697 KB
sqlite-3.32.3             |       h2a8f88b_0         1.2 MB
vc-14.1                   |       h0510ff6_4           6 KB
vs2015_runtime-14.16.27012 |       hf0eaf9b_2         2.2 MB
wheel-0.34.2               |           py36_0         66 KB
wincertstore-0.2           |   py36hcdd9a18_0         14 KB
zlib-1.2.11               |       h33f27b4_4         116 KB
------------------------------------------------------------
                                      Total:       26.0 MB

The following NEW packages will be INSTALLED:

certifi pkgs/main/win-32::certifi-2020.6.20-py36_0 pip pkgs/main/win-32::pip-20.1.1-py36_1 python pkgs/main/win-32::python-3.6.10-h9f7ef89_2 setuptools pkgs/main/win-32::setuptools-47.3.1-py36_0 sqlite pkgs/main/win-32::sqlite-3.32.3-h2a8f88b_0 vc pkgs/main/win-32::vc-14.1-h0510ff6_4 vs2015_runtime pkgs/main/win-32::vs2015_runtime-14.16.27012-hf0eaf9b_2 wheel pkgs/main/win-32::wheel-0.34.2-py36_0 wincertstore pkgs/main/win-32::wincertstore-0.2-py36hcdd9a18_0 zlib pkgs/main/win-32::zlib-1.2.11-h33f27b4_4

Proceed ([y]/n)? y

Downloading and Extracting Packages wheel-0.34.2 | 66 KB | ############################################################################################################ | 100% wincertstore-0.2 | 14 KB | ############################################################################################################ | 100% zlib-1.2.11 | 116 KB | ############################################################################################################ | 100% vc-14.1 | 6 KB | ############################################################################################################ | 100% python-3.6.10 | 19.5 MB | ############################################################################################################ | 100% sqlite-3.32.3 | 1.2 MB | ############################################################################################################ | 100% pip-20.1.1 | 2.1 MB | ############################################################################################################ | 100% vs2015_runtime-14.16 | 2.2 MB | ############################################################################################################ | 100% setuptools-47.3.1 | 697 KB | ############################################################################################################ | 100% certifi-2020.6.20 | 160 KB | ############################################################################################################ | 100% Preparing transaction: done Verifying transaction: done Executing transaction: done #

To activate this environment, use

#

$ conda activate env_name

#

To deactivate an active environment, use

#

$ conda deactivate

D:.net project\pythonProject\爬虫\控制windows系统>conda activate python32 Could not find conda environment: python32 You can list all discoverable environments with conda info --envs.

D:.net project\pythonProject\爬虫\控制windows系统>conda info

 active environment : None
  user config file : C:\Users\24497\.condarc

populated config files : conda version : 4.8.3 conda-build version : 3.10.5 python version : 3.6.10.final.0 virtual packages : base environment : D:\soft\Anaconda (writable) channel URLs : https://repo.anaconda.com/pkgs/main/win-32 https://repo.anaconda.com/pkgs/main/noarch https://repo.anaconda.com/pkgs/r/win-32 https://repo.anaconda.com/pkgs/r/noarch https://repo.anaconda.com/pkgs/msys2/win-32 https://repo.anaconda.com/pkgs/msys2/noarch package cache : D:\soft\Anaconda\pkgs32 C:\Users\24497.conda\pkgs32 C:\Users\24497\AppData\Local\conda\conda\pkgs32 envs directories : D:\soft\Anaconda\envs C:\Users\24497.conda\envs C:\Users\24497\AppData\Local\conda\conda\envs platform : win-32 user-agent : conda/4.8.3 requests/2.18.4 CPython/3.6.10 Windows/10 Windows/10.0.18362 administrator : False netrc file : None offline mode : False

 

 

 

 

 

 

 

 

 

 

 

Anaconda的一些命令 1.查看当前工作平台:conda info

(base) C:\Users\Catlin Cao>conda info

 (base) C:\Users\Catlin Cao>conda info

    active environment : base
  active env location : F:\Anaconda3
          shell level : 1
      user config file : C:\Users\Catlin Cao\.condarc
populated config files : C:\Users\Catlin Cao\.condarc
        conda version : 4.5.11
  conda-build version : 3.15.1
        python version : 3.7.0.final.0
      base environment : F:\Anaconda3 (writable)
          channel URLs : https://repo.anaconda.com/pkgs/main/win-32
                        https://repo.anaconda.com/pkgs/main/noarch
                        https://repo.anaconda.com/pkgs/free/win-32
                        https://repo.anaconda.com/pkgs/free/noarch
                        https://repo.anaconda.com/pkgs/r/win-32
                        https://repo.anaconda.com/pkgs/r/noarch
                        https://repo.anaconda.com/pkgs/pro/win-32
                        https://repo.anaconda.com/pkgs/pro/noarch
                        https://repo.anaconda.com/pkgs/msys2/win-32
                        https://repo.anaconda.com/pkgs/msys2/noarch
        package cache : F:\Anaconda3\pkgs32
                        C:\Users\Catlin Cao\AppData\Local\conda\conda\pkgs32
      envs directories : F:\Anaconda3\envs
                        C:\Users\Catlin Cao\AppData\Local\conda\conda\envs
                        C:\Users\Catlin Cao\.conda\envs
              platform : win-32
            user-agent : conda/4.5.11 requests/2.19.1 CPython/3.7.0 Windows/10 Windows/10.0.17134
        administrator : False
            netrc file : None
          offline mode : False

可见此时是32位平台。

2.切换64位和32位:set CONDA_FORCE_32BIT=1是切换到32位;set CONDA_FORCE_32BIT= 是切换到64位。

需要注意的是,这样切换环境对于已经安装的python没有任何影响,即原先是64位的python,现在还是64位,所以需要切换到32位后再安装python,并且安装需要在prompt下进行,在navigator里新建的python默认是64位的。

3.安装python:conda create -n env_name python=3.6,如果需要安装一些包,只需要在name后加上对应的包名称。conda create -n env_name numpy matplotlib python=3.6。

4.切换环境:conda activate env_name,conda deactivate env_name。

5.移除环境:conda remove -n env_name --all

6.安装包:activate env_name,conda install pandas。安装anaconda发行版的所有包:conda install anaconda,但是这样会在所有环境都执行这样的操作,所以需要指定安装环境:conda install -n env_name pandas

以上的操作都是在Anaconda Prompt里,其实用Anaconda图形界面(Navigator)安装python会更加直观,但是需要注意的是,无论你是否在Prompt里设置了32位的环境,用Navigator安装的python都是64位的,大家可以试一下,有异议欢迎留言交流。

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

今天需要调用一个dll动态函数库,但是本地的python是64位的,dll是32位的,直接调用会报错。

OSError: [WinError 193] %1 不是有效的 Win32 应用程序。 1 python版本:3.6 anaconda对于python版本的管理还是很方便的,所以这里用anaconda才实现32位和64位python共存 1、打开anaconda prompt,输入 conda info ,可以看到现在用的是64位的。

 

2、切换成32位的 set CONDA_FORCE_32BIT=1 可以看出已经切换成32位的了

 

3、安装32位的python3.6 conda create -n python32 python=3.6

 

安装完成后在anaconda3文件夹下面会有一个envs文件夹

 

4、激活环境 conda activate python32 ,如果要取消 conda deactivate python32,如果要删除环境 conda remove -n python32--all 5、如果要在pycharm中使用该环境

 

点击add local

 

点击ok就行了

posted on 2022-08-10 08:41  root-123  阅读(777)  评论(0编辑  收藏  举报