一、安裝Anaconda
Anaconda是一個開源的包、環境管理器,可以用於在同一個機器上安裝不同版本的軟件包及其依賴,並能夠在不同的環境之間切換。
Anaconda包括Conda、Python以及一大堆安裝好的工具包,比如:numpy等
1、安裝完成后啟動
2、修改Anaconda鏡像地址
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes
3、安裝jpype1-手動方式
自動方式安裝(pip install jpype1)會報錯,選擇手動方式; Anaconda已自帶wheel不須再安裝
下載.whl文件:JPype1-0.6.3-cp37-cp37m-win_amd64.whl
下載路徑:https://www.lfd.uci.edu/~gohlke/pythonlibs/#jpype
安裝:pip install C:\Users\gaogao\Downloads\JPype1-0.6.3-cp37-cp37m-win_amd64.whl
二、安裝PyCharm
1、設置字體及大小
File->Settings
三、報錯匯總
1、ModuleNotFoundError: No module named 'jpype'
解決:python 中調用java代碼需要安裝 jpype1 。
2、ImportError: numpy.core.multiarray failed to import
解決:python 安裝numpy。
3、報錯:numpy-1.16.1+mkl-cp37-cp37m-win_amd64.whl is not a supported wheel on this platform.
解決:python版本位數與whl文件位數要保持一致.(本地python32位換成64位)
4、打包成exe后執行閃退
解決:將.exe文件手動到DOS窗口可查看日志
5、 error: Microsoft Visual C++ 14.0 is required.
Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools
解決:安裝jpype時報的錯,由於c++依賴庫不存在,所以在對包進行編譯的時候出錯,故我們可以去直接下載二進制安裝包進行安裝。(即自動方式安裝)
6、 Could not install packages due to an EnvironmentError: [WinError 5]
權限不足,需要管理員身份運行
拒絕訪問。:
'c:\\program files\\python37\\lib\\site-packages\\pip-18.1.dist-info\\entry_points.txt'
Consider using the `--user` option or check the permissions.
解決一:使用C:\Windows\System32 文件夾下面的cmd.exe
解決二:python -m pip install --upgrade pip改成python -m pip install --user --upgrade pip
7、 打包好的exe執行報錯:
ImportError: numpy.core.multiarray failed to import
解決方法01,改變控制台的編碼格式為utf-8,在控制台中輸入 chcp 65001,然后再使用pyinstaller -D xxx.py 打包成功。
解決方法02:源代碼中startJVM的順序調整一下:
app = App(root) classpath = os.path.join(os.path.abspath('.'), './') startJVM(getDefaultJVMPath(), "-ea", "-Djava.class.path=%s" %(classpath)) javaClass = JClass('Test') #問題根因是App()實例初始化在startJVM之后導致的。
解決方法03:將打包好的文件夾先拷貝到其他盤(不要在C盤),再以管理員身份運行
8、No matching distribution found for pyinstaller
Could not find a version that satisfies the requirement pyinstaller (from versions: )
No matching distribution found for pyinstaller
解決:網絡慢,可通過鏡像下載:
pip install pyinstaller -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
9、Pip install jpype1 報錯
building '_jpype' extension
error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools":
解決:下載visualcppbuildtools_full.exe
10 jpype._jexception.RuntimeExceptionPyRaisable: java.lang.RuntimeException: Class Test not found
Traceback (most recent call last):
File "

File "site-packages\jpype\_

jpype._jexception.RuntimeExceptionPyRaisable: java.lang.RuntimeException: Class Test not found
[5876] Failed to execute script my_test