2017-04-07 114 views
0

你好我正在爲我的web應用使用pythonanywhere.com,並且我找到一種方法來導入pyexcel供我使用,但是好像我不能這樣做,因爲這個錯誤。 Im新的Web應用程序開發。所以,請。我需要幫助。導入pyexcel-xlxs時出錯

當我通過從GitHub克隆它安裝了它,它這樣做:

$ git clone http://github.com/pyexcel/pyexcel-xlsx.git 
    $ cd pyexcel-xlsx 
    $ python setup.py install 

但我在這裏得到了一個錯誤:

13:56 ~ $ git clone http://github.com/pyexcel/pyexcel-xlsx.git 
Cloning into 'pyexcel-xlsx'... 
remote: Counting objects: 808, done. 
remote: Compressing objects: 100% (7/7), done. 
remote: Total 808 (delta 1), reused 0 (delta 0), pack-reused 801 
Receiving objects: 100% (808/808), 167.27 KiB | 0 bytes/s, done. 
Resolving deltas: 100% (473/473), done. 
Checking connectivity... done. 
13:56 ~ $ cd pyexcel-xlsx 
13:57 ~/pyexcel-xlsx (master)$ python setup.py install 
running install 
error: can't create or remove files in install directory 
The following error occurred while trying to add or remove files in the 
installation directory: 
    [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/test-easy-install-22208.write-test' 
The installation directory you specified (via --install-dir, --prefix, or 
the distutils default setting) was: 
    /usr/local/lib/python2.7/dist-packages/ 
Perhaps your account does not have write access to this directory? If the 
installation directory is a system-owned directory, you may need to sign in 
as the administrator or "root" account. If you do not have administrative 
access to this machine, you may wish to choose a different installation 
directory, preferably one that is listed in your PYTHONPATH environment 
variable. 
For information on other options, you may wish to consult the 
documentation at: 
    https://setuptools.readthedocs.io/en/latest/easy_install.html 
Please make the appropriate changes for your system and try again. 

回答

1

由於您使用PythonAnywhere的標準Python ,而不是構建虛擬環境(在您的控制之下)setup.py正試圖安裝到系統site-packages目錄中,在那裏你只有hav e讀取權限。如果您想要在沒有虛擬環境的情況下繼續操作,請在您自己的區域創建一個目錄,並告訴setup.py使用--install-lib dirname選項在那裏安裝它。

然後將PYTHONPATH shell環境變量設置爲該目錄的export PYTHONPATH=dirname,以便解釋器將該目錄添加到其模塊搜索路徑,您應該很好。

+0

你好@holdenweb我跟着你的建議,並正確地安裝它,但我似乎有不同的問題現在。 \t'進口fileinput' \t'進口csv' '從pyexcel_xlsx進口get_data' '數據= GET_DATA( 「file.xlsx」)'' 進口json' 線'從pyexcel'得到一個語法錯誤:( – dekt

+0

' from pyexcel_xlsx import csv',probably? – holdenweb

0

@ holdenweb的指令是好的,但一個更快的方式就是在bash控制檯運行此:

pip2.7 install --user https://github.com/pyexcel/pyexcel-xlsx/archive/master.zip 
+0

它工作,但是當我編碼。從pyexcel_xlsx導入get_data'的代碼仍然是語法錯誤。任何想法爲什麼?它已成功安裝,但這種情況發生 – dekt

+0

我看到你已經關於堆棧溢出打開另一個問題,所以我會回答:http://stackoverflow.com/questions/43314087/pyexcel-xlsx-successfully-installed-but-importing-is-still-on-syntax-error –