1
大家晚上好,Python腳本可以在一個文件夾中工作,但不能在子文件夾中工作。
我試圖做一些機器與Python學習,所以我輸入模塊scikit學習:
from sklearn.preprocessing import MinMaxScaler
,這讓我這個奇怪的錯誤:
Traceback (most recent call last):
File "<ipython-input-22-b55a4eaccb0b>", line 1, in <module>
from sklearn.preprocessing import MinMaxScaler
File "C:\Users\Francesco\Anaconda3\lib\site-packages\sklearn\preprocessing\__init__.py", line 6, in <module>
from ._function_transformer import FunctionTransformer
File "C:\Users\Francesco\Anaconda3\lib\site-packages\sklearn\preprocessing\_function_transformer.py", line 2, in <module>
from ..utils import check_array
File "C:\Users\Francesco\Anaconda3\lib\site-packages\sklearn\utils\__init__.py", line 18, in <module>
from ..externals.joblib import cpu_count
File "C:\Users\Francesco\Anaconda3\lib\site-packages\sklearn\externals\joblib\__init__.py", line 128, in <module>
from .parallel import Parallel
File "C:\Users\Francesco\Anaconda3\lib\site-packages\sklearn\externals\joblib\parallel.py", line 24, in <module>
from ._multiprocessing_helpers import mp
File "C:\Users\Francesco\Anaconda3\lib\site-packages\sklearn\externals\joblib\_multiprocessing_helpers.py", line 24, in <module>
_sem = mp.Semaphore()
AttributeError: module 'multiprocessing' has no attribute 'Semaphore'
這些錯誤是從Anaconda(Spider)複製而來的,但它們即使從命令行啓動python會話也是存在的。在這裏我要運行腳本的文件夾是:
C:\Users\Francesco\Desktop\script_python
的很奇怪的事情是,如果我從桌面運行相同的腳本,只是一個文件夾時,它的工作原理!
C:\Users\Francesco\Desktop\ <-- Here it works!!
我發現這個問題是相對於多模塊,這裏的這種奇怪的行爲快照:你在哪裏運行
桌面上是否有任何名爲'multiprocessing'的目錄(隱藏'multiprocessing'模塊)。你可以嘗試'python -c「import multiprocessing; print(multiprocessing .__ dir __)」' –
噢,上帝,我在該文件夾中有一個名爲multiprocessing的模塊,我完全忘了!太棒了,把它作爲答案我會接受它! – FrAxl93