小弟使用的是Anaconda 沒有內建twstock模組,得自行安裝
安裝過程不太順利,因為使用anaconda prompt 沒有admin的權限
不是windows帳號本身的問題,而是anaconda prompt 沒有admin的權限@@,不知道怎麼讓它有權限
而anaconda prompt 跟cmd的差別是,前者是anaconda的環境變數,但是cmd卻沒有
所以先手工設定windows 系統環境變數內的path,將下面藍色跟conda 及python的pathc放進去後
請先爬文參考windows 系統環境變數設定方法,將conda, python的path寫進去
然後再使用admin的權限去安裝twstock 模組
2nd try (2020.08.13 update)
今天用一台全新的電腦,先安anaconda後再手動安裝twsotck
在anaconda 環境下,打開 terminal
在CMD之下,使用"pip install twstock" 安裝,這次倒是很順利
以下是小弟第一次安裝過程(2019.12.24)
首先是傻傻地在anaconda prompt下安裝,碰了一屁股灰
(base) C:\Users\ASUS>pip install twstock
Collecting twstock
Downloading https://files.pythonhosted.org/packages/38/a0/61e6b65093a7564cb8e34aea54de28113bfe24409fb05e173360fbf5a35d/twstock-1.3.1-py3-none-any.whl (1.9MB)
100% |████████████████████████████████| 1.9MB 2.1MB/s
Requirement already satisfied: requests in c:\program files (x86)\microsoft visual studio\shared\anaconda3_64\lib\site-packages (from twstock) (2.18.4)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in c:\program files (x86)\microsoft visual studio\shared\anaconda3_64\lib\site-packages (from requests->twstock) (3.0.4)
Requirement already satisfied: idna<2.7,>=2.5 in c:\program files (x86)\microsoft visual studio\shared\anaconda3_64\lib\site-packages (from requests->twstock) (2.6)
Requirement already satisfied: urllib3<1.23,>=1.21.1 in c:\program files (x86)\microsoft visual studio\shared\anaconda3_64\lib\site-packages (from requests->twstock) (1.22)
Requirement already satisfied: certifi>=2017.4.17 in c:\program files (x86)\microsoft visual studio\shared\anaconda3_64\lib\site-packages (from requests->twstock) (2018.4.16)
distributed 1.21.8 requires msgpack, which is not installed.
Installing collected packages: twstock
Could not install packages due to an EnvironmentError: [WinError 5] 存取被拒。: 'C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\Anaconda3_64\\Lib\\site-packages\\twstock'
Consider using the `--user` option or check the permissions.
You are using pip version 10.0.1, however version 19.3.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
似乎出現的不好錯誤,開始來除蟲囉
1. 找出pthon & conda path,加進系統環境變數內,要重開機
先用anaconda promt \ where pythom & where conda path,將下面藍色的Path加進windows的系統環境變數內
(base) C:\Users\ASUS>where conda
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\Library\bin\conda.bat
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\Scripts\conda.exe
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\condabin\conda.bat
(base) C:\Users\ASUS>where python
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\python.exe
C:\Users\ASUS\AppData\Local\Microsoft\WindowsApps\python.exe
2. 然後再用系統管理員打開cmd,再安裝一次
C:\WINDOWS\system32>pip install twstock
Collecting twstock
Using cached https://files.pythonhosted.org/packages/38/a0/61e6b65093a7564cb8e34aea54de28113bfe24409fb05e173360fbf5a35d/twstock-1.3.1-py3-none-any.whl
Requirement already satisfied: requests in c:\program files (x86)\microsoft visual studio\shared\anaconda3_64\lib\site-packages (from twstock) (2.18.4)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in c:\program files (x86)\microsoft visual studio\shared\anaconda3_64\lib\site-packages (from requests->twstock) (3.0.4)
Requirement already satisfied: idna<2.7,>=2.5 in c:\program files (x86)\microsoft visual studio\shared\anaconda3_64\lib\site-packages (from requests->twstock) (2.6)
Requirement already satisfied: urllib3<1.23,>=1.21.1 in c:\program files (x86)\microsoft visual studio\shared\anaconda3_64\lib\site-packages (from requests->twstock) (1.22)
Requirement already satisfied: certifi>=2017.4.17 in c:\program files (x86)\microsoft visual studio\shared\anaconda3_64\lib\site-packages (from requests->twstock) (2018.4.16)
distributed 1.21.8 requires msgpack, which is not installed.
Installing collected packages: twstock
The script twstock.exe is installed in 'C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed twstock-1.3.1
You are using pip version 10.0.1, however version 19.3.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
C:\WINDOWS\system32>where twstock
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\Scripts\twstock.exe
到此為止,我們安裝成功囉,下一篇再來使用twstock模組抓台股資料
Reference
- TWSTOCK 台灣股票價格擷取
- Python 大數據特訓班 文淵閣編著 碁峯
- error fixing Q & A
留言列表