2017-04-07 74 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 –