python 从ubantu环境迁移到windows环境
下载安装Anaconda3
Anaconda3-2021.05-Windows-x86_64.exe
默认安装目录
C:\ProgramData\Anaconda3
可以启动Anaconda查看不同的环境
也可打开Powershell进行命令行操作
创建一个Python36环境
这里用到了tensorflow1.8,只能安装python36
conda create --name tf1 python=3.6
conda env list
PS D:\wks_ai> conda env list # conda environments: # base * C:\ProgramData\Anaconda3 tf1 C:\Users\len\.conda\envs\tf1
(base) PS C:\Users\len> conda activate tf1 (tf1) PS C:\Users\len> python Python 3.6.13 |Anaconda, Inc.| (default, Mar 16 2021, 11:37:27) [MSC v.1916 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>>
vscode配置
ctrl + Shift + P
选择解释器
从原环境中导出一份pip list
pip freeze > tf1.txt
absl-py==0.13.0 astor==0.8.1 bleach==1.5.0 certifi==2021.5.30 cycler==0.10.0 dataclasses==0.8 gast==0.5.0 grpcio==1.38.1 html5lib==0.9999999 importlib-metadata==4.6.1 joblib==1.0.1 Keras==2.0.0 kiwisolver==1.3.1 Markdown==3.3.4 matplotlib==3.3.4 numpy==1.18.1 pandas==1.1.5 Pillow==8.3.1 protobuf==3.17.3 pyparsing==2.4.7 python-dateutil==2.8.1 pytz==2021.1 PyYAML==5.4.1 scikit-learn==0.24.2 scipy==1.5.4 six==1.16.0 sklearn==0.0 tensorboard==1.8.0 tensorflow==1.8.0 termcolor==1.1.0 threadpoolctl==2.2.0 typing-extensions==3.10.0.0 Werkzeug==2.0.1 zipp==3.5.0
依次安装下面这些包
pip install numpy==1.18.1 pip install matplotlib==3.3.4 pip install pandas==1.1.5 pip install scikit-learn==0.24.2 pip install six==1.16.0 pip install zipp==3.5.0 pip install tensorflow==1.8.0 pip install Keras==2.0.0
windows环境补充安装
pip install win_unicode_console
设置自定义python模块路径
python -c "print('\n'.join(__import__('sys').path))"
(base) ai@ai:/opt/app/anaconda3/envs/py37/lib/python3.7/site-packages$ conda activate py37 (py37) ai@ai:/opt/app/anaconda3/envs/py37/lib/python3.7/site-packages$ python -c "print('\n'.join(__import__('sys').path))" /opt/aidoc/aitools/ait /opt/app/anaconda3/envs/py37/lib/python37.zip /opt/app/anaconda3/envs/py37/lib/python3.7 /opt/app/anaconda3/envs/py37/lib/python3.7/lib-dynload /opt/app/anaconda3/envs/py37/lib/python3.7/site-packages (py37) ai@ai:/opt/app/anaconda3/envs/py37/lib/python3.7/site-packages$ cd /opt/app/anaconda3/envs/py37/lib/python3.7/site-packages (py37) ai@ai:/opt/app/anaconda3/envs/py37/lib/python3.7/site-packages$ vim ait.pth (py37) ai@ai:/opt/app/anaconda3/envs/py37/lib/python3.7/site-packages$ (py37) ai@ai:/opt/app/anaconda3/envs/py37/lib/python3.7/site-packages$ cat ait.pth /opt/aisty/doc/aitools/ait