简体   繁体   English

无法使用sudo pip3安装Networkit安装Networkit

[英]Unable to install Networkit using sudo pip3 install networkit

I have been trying to install Networkit using sudo pip3 install networkit as described in their website but i get this error! 我一直在尝试使用sudo pip3 install networkit来安装Networkit,如其网站所述,但出现此错误!

Collecting networkit
  Downloading networkit-4.1.1.tar.gz (936kB)
    100% |████████████████████████████████| 942kB 1.6MB/s 
Installing collected packages: networkit
  Running setup.py install for networkit ... error
    Complete output from command /Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5 -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-p2tcuarv/networkit/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-ac3b1wc7-record/install-record.txt --single-version-externally-managed --compile:
    /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/Cython/Distutils/old_build_ext.py:30: UserWarning: Cython.Distutils.old_build_ext does not properly handle dependencies and is deprecated.
      "Cython.Distutils.old_build_ext does not properly handle dependencies "
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.6-intel-3.5
    creating build/lib.macosx-10.6-intel-3.5/networkit
    copying networkit/__init__.py -> build/lib.macosx-10.6-intel-3.5/networkit
    copying networkit/algebraic.py -> build/lib.macosx-10.6-intel-3.5/networkit
    copying networkit/centrality.py -> build/lib.macosx-10.6-intel-3.5/networkit
    copying networkit/clique.py -> build/lib.macosx-10.6-intel-3.5/networkit
    copying networkit/coarsening.py -> build/lib.macosx-10.6-intel-3.5/networkit
    copying networkit/coloring.py -> build/lib.macosx-10.6-intel-3.5/networkit
    copying networkit/community.py -> build/lib.macosx-10.6-intel-3.5/networkit
    copying networkit/components.py -> build/lib.macosx-10.6-intel-3.5/networkit
    copying networkit/correlation.py -> build/lib.macosx-10.6-intel-3.5/networkit
    copying networkit/distance.py -> build/lib.macosx-10.6-intel-3.5/networkit
    copying networkit/dynamic.py -> build/lib.macosx-10.6-intel-3.5/networkit
    copying networkit/engineering.py -> build/lib.macosx-10.6-intel-3.5/networkit
    copying networkit/flow.py -> build/lib.macosx-10.6-intel-3.5/networkit
    copying networkit/generators.py -> build/lib.macosx-10.6-intel-3.5/networkit
    copying networkit/GEXFIO.py -> build/lib.macosx-10.6-intel-3.5/networkit
    copying networkit/globals.py -> build/lib.macosx-10.6-intel-3.5/networkit
    copying networkit/graph.py -> build/lib.macosx-10.6-intel-3.5/networkit
    copying networkit/graphio.py -> build/lib.macosx-10.6-intel-3.5/networkit
    copying networkit/GraphMLIO.py -> build/lib.macosx-10.6-intel-3.5/networkit
    copying networkit/linkprediction.py -> build/lib.macosx-10.6-intel-3.5/networkit
    copying networkit/matching.py -> build/lib.macosx-10.6-intel-3.5/networkit
    copying networkit/nxadapter.py -> build/lib.macosx-10.6-intel-3.5/networkit
    copying networkit/partitioning.py -> build/lib.macosx-10.6-intel-3.5/networkit
    copying networkit/plot.py -> build/lib.macosx-10.6-intel-3.5/networkit
    copying networkit/sampling.py -> build/lib.macosx-10.6-intel-3.5/networkit
    copying networkit/scd.py -> build/lib.macosx-10.6-intel-3.5/networkit
    copying networkit/simulation.py -> build/lib.macosx-10.6-intel-3.5/networkit
    copying networkit/sparsification.py -> build/lib.macosx-10.6-intel-3.5/networkit
    copying networkit/stats.py -> build/lib.macosx-10.6-intel-3.5/networkit
    copying networkit/stopwatch.py -> build/lib.macosx-10.6-intel-3.5/networkit
    copying networkit/structures.py -> build/lib.macosx-10.6-intel-3.5/networkit
    copying networkit/viztasks.py -> build/lib.macosx-10.6-intel-3.5/networkit
    copying networkit/workflows.py -> build/lib.macosx-10.6-intel-3.5/networkit
    creating build/lib.macosx-10.6-intel-3.5/networkit/gephi
    copying networkit/gephi/__init__.py -> build/lib.macosx-10.6-intel-3.5/networkit/gephi
    copying networkit/gephi/csv.py -> build/lib.macosx-10.6-intel-3.5/networkit/gephi
    copying networkit/gephi/pyclient.py -> build/lib.macosx-10.6-intel-3.5/networkit/gephi
    copying networkit/gephi/streaming.py -> build/lib.macosx-10.6-intel-3.5/networkit/gephi
    creating build/lib.macosx-10.6-intel-3.5/networkit/profiling
    copying networkit/profiling/__init__.py -> build/lib.macosx-10.6-intel-3.5/networkit/profiling
    copying networkit/profiling/job.py -> build/lib.macosx-10.6-intel-3.5/networkit/profiling
    copying networkit/profiling/multiprocessing_helper.py -> build/lib.macosx-10.6-intel-3.5/networkit/profiling
    copying networkit/profiling/plot.py -> build/lib.macosx-10.6-intel-3.5/networkit/profiling
    copying networkit/profiling/profiling.py -> build/lib.macosx-10.6-intel-3.5/networkit/profiling
    copying networkit/profiling/stat.py -> build/lib.macosx-10.6-intel-3.5/networkit/profiling
    creating build/lib.macosx-10.6-intel-3.5/networkit/test
    copying networkit/test/__init__.py -> build/lib.macosx-10.6-intel-3.5/networkit/test
    copying networkit/test/test_algorithms.py -> build/lib.macosx-10.6-intel-3.5/networkit/test
    copying networkit/test/test_community.py -> build/lib.macosx-10.6-intel-3.5/networkit/test
    copying networkit/test/test_graphio.py -> build/lib.macosx-10.6-intel-3.5/networkit/test
    copying networkit/test/test_sparsification.py -> build/lib.macosx-10.6-intel-3.5/networkit/test
    creating build/lib.macosx-10.6-intel-3.5/networkit/test/extension
    copying networkit/test/extension/__init__.py -> build/lib.macosx-10.6-intel-3.5/networkit/test/extension
    copying networkit/test/extension/test.py -> build/lib.macosx-10.6-intel-3.5/networkit/test/extension
    creating build/lib.macosx-10.6-intel-3.5/networkit/test/gephi
    copying networkit/test/gephi/__init__.py -> build/lib.macosx-10.6-intel-3.5/networkit/test/gephi
    creating build/lib.macosx-10.6-intel-3.5/networkit/profiling/html
    copying networkit/profiling/html/measure.html -> build/lib.macosx-10.6-intel-3.5/networkit/profiling/html
    copying networkit/profiling/html/overlay.html -> build/lib.macosx-10.6-intel-3.5/networkit/profiling/html
    copying networkit/profiling/html/profile.html -> build/lib.macosx-10.6-intel-3.5/networkit/profiling/html
    copying networkit/profiling/html/profiling.css -> build/lib.macosx-10.6-intel-3.5/networkit/profiling/html
    copying networkit/profiling/html/profiling.js -> build/lib.macosx-10.6-intel-3.5/networkit/profiling/html
    creating build/lib.macosx-10.6-intel-3.5/networkit/profiling/latex
    copying networkit/profiling/latex/measure.tex -> build/lib.macosx-10.6-intel-3.5/networkit/profiling/latex
    copying networkit/profiling/latex/profile.tex -> build/lib.macosx-10.6-intel-3.5/networkit/profiling/latex
    creating build/lib.macosx-10.6-intel-3.5/networkit/profiling/description
    copying networkit/profiling/description/descriptions.txt -> build/lib.macosx-10.6-intel-3.5/networkit/profiling/description
    running build_ext
    initializing NetworKit compilation with: scons --optimize=Opt --target=Core -j8 --compiler=g++-4.8 --std=c++11
    scons: Reading SConscript files ...
    scons: done reading SConscript files.
    scons: Building targets ...
    g++-4.8 -o .buildOpt/algebraic/AdjacencyMatrix.o -c -std=c++11 -Wall -c -fmessage-length=0 -fPIC -fopenmp -O3 -DNDEBUG -DLOG_LEVEL=LOG_LEVEL_INFO networkit/cpp/algebraic/AdjacencyMatrix.cpp
    g++-4.8 -o .buildOpt/algebraic/CSRMatrix.o -c -std=c++11 -Wall -c -fmessage-length=0 -fPIC -fopenmp -O3 -DNDEBUG -DLOG_LEVEL=LOG_LEVEL_INFO networkit/cpp/algebraic/CSRMatrix.cpp
    g++-4.8 -o .buildOpt/algebraic/DenseMatrix.o -c -std=c++11 -Wall -c -fmessage-length=0 -fPIC -fopenmp -O3 -DNDEBUG -DLOG_LEVEL=LOG_LEVEL_INFO networkit/cpp/algebraic/DenseMatrix.cpp
    g++-4.8 -o .buildOpt/algebraic/DiagonalMatrix.o -c -std=c++11 -Wall -c -fmessage-length=0 -fPIC -fopenmp -O3 -DNDEBUG -DLOG_LEVEL=LOG_LEVEL_INFO networkit/cpp/algebraic/DiagonalMatrix.cpp
    g++-4.8 -o .buildOpt/algebraic/IncidenceMatrix.o -c -std=c++11 -Wall -c -fmessage-length=0 -fPIC -fopenmp -O3 -DNDEBUG -DLOG_LEVEL=LOG_LEVEL_INFO networkit/cpp/algebraic/IncidenceMatrix.cpp
    g++-4.8 -o .buildOpt/algebraic/LaplacianMatrix.o -c -std=c++11 -Wall -c -fmessage-length=0 -fPIC -fopenmp -O3 -DNDEBUG -DLOG_LEVEL=LOG_LEVEL_INFO networkit/cpp/algebraic/LaplacianMatrix.cpp
    g++-4.8 -o .buildOpt/algebraic/Matrix.o -c -std=c++11 -Wall -c -fmessage-length=0 -fPIC -fopenmp -O3 -DNDEBUG -DLOG_LEVEL=LOG_LEVEL_INFO networkit/cpp/algebraic/Matrix.cpp
    g++-4.8 -o .buildOpt/algebraic/NormalizedLaplacianMatrix.o -c -std=c++11 -Wall -c -fmessage-length=0 -fPIC -fopenmp -O3 -DNDEBUG -DLOG_LEVEL=LOG_LEVEL_INFO networkit/cpp/algebraic/NormalizedLaplacianMatrix.cpp
    /var/tmp//ccFjDjJZ.s:17:expecting string instruction after `rep'
    /var/tmp//ccFjDjJZ.s:56:expecting string instruction after `rep'
    scons: *** [.buildOpt/algebraic/DenseMatrix.o] Error 1
    /var/tmp//cch6WQOj.s:17:expecting string instruction after `rep'
    /var/tmp//cch6WQOj.s:56:expecting string instruction after `rep'
    /var/tmp//cch6WQOj.s:3864:expecting string instruction after `rep'
    /var/tmp//cch6WQOj.s:3869:expecting string instruction after `rep'
    scons: *** [.buildOpt/algebraic/Matrix.o] Error 1
    /var/tmp//ccjOB51r.s:17:expecting string instruction after `rep'
    scons: *** [.buildOpt/algebraic/CSRMatrix.o] Error 1
    scons: building terminated because of errors.
    scons returned an error, exiting setup.py

    ----------------------------------------
Command "/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5 -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-p2tcuarv/networkit/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-ac3b1wc7-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/tmp/pip-build-p2tcuarv/networkit/

It's probably to do with you using OSX. 使用OSX可能与您有关。 I have LOADS of problems with it. 我有很多问题。 It's a common problem with NetworKit that the installation causes many weird problems for MacOSX. NetworKit的一个常见问题是安装会导致MacOSX出现许多奇怪的问题。

Try and follow these tips or see what I've done that might help solve your problem. 尝试并遵循这些提示,或者查看我所做的可能有助于解决您的问题的步骤。

  • use the ARCHFLAGS="-arch x86_64" flag --- this has been known to fix some Mac config settings 使用ARCHFLAGS =“-arch x86_64”标志---已知可以修复某些Mac配置设置
  • use c/c++ compiler gcc-4 (I recommend gcc 4.8 but 4.9 should be ok) --- UPDATE. 使用c / c ++编译器gcc-4(我建议使用gcc 4.8,但4.9应该可以)---更新。 I successfully followed this guide using gcc-6 [my version: Homebrew gcc 6.2.0 --without-multilib] so if you want to use gcc-6 it should be ok. 我使用gcc-6 [我的版本:Homebrew gcc 6.2.0 --without-multilib]成功地遵循了该指南,因此,如果您想使用gcc-6,应该没问题。 --- ---
  • ensure you have all the dependencies 确保您拥有所有依赖项
  • use a modern python3 (eg the most recent 3.5) 使用现代的python3(例如最新的3.5)

Here's a possible step by step guide that might help you out. 这是一个可能的逐步指南,可能会对您有所帮助。

Step 1: Ensure you have gcc-4.8 or gcc-4.9 installed and modern python3: for example: 第1步:确保已安装gcc-4.8或gcc-4.9和现代的python3:例如:

$ gcc-4.8 --version
gcc-4.8 (Homebrew gcc48 4.8.5) 4.8.5 ....
$ python3 --version
Python 3.5.2

((If you don't have these installed, I recommend using homebrew to install it using (((如果您没有安装这些工具,建议您使用homebrew

$ brew install gcc48  # installs gcc-4.8 and g++-4.8

)

If you need homebrew, see http://brew.sh/ or just run: 如果您需要自制软件,请访问http://brew.sh/或直接运行:

$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

)

Step 2: Edit your .profile or .bash_profile scripts in your home (~) so that your Terminal has helpful settings for installing NetworKit. 步骤2:在您的家庭(〜)中编辑.profile或.bash_profile脚本,以便您的终端机具有安装NetworKit的有用设置。 For example: 例如:

Dir$ echo $HOME  # Check what this is set to -- it should be similar for you
/Users/GFenn
Dir$ echo ~  # this should be the same as above
/Users/GFenn
Dir$ cd
~$ nano .profile #[or use "vim" or "echo >> " if you prefer]

##WHILE IN .profile (or whatever), ADD THE FOLLOWING LINES AT THE END
# Temporary configurations to help install NetworKit
CC="gcc-4.8"
CXX="g++-4.8"
ARCHFLAGS="-arch x86_64"
alias gcc="gcc-4.8"
alias g++="g++4.8"
##WHEN NETWORKIT IS INSTALLED, YOU CAN DELETE THESE LINES OR COMMENT OUT WITH #s

Step 3: Load these settings. 步骤3:加载这些设置。 Easy - just close and reopen your terminal 轻松-只需关闭并重新打开终端

$ exit

Step 4: Install the dependent or useful python3 modules: 步骤4:安装相关或有用的python3模块:

 $ sudo pip3 install pandas seaborn scipy numpy matplotlib tabulate networkx cython sklearn ipython

(If you have these modules already you shouldn't need to worry: but if you want to be sure you have fresh modules: (如果您已经有了这些模块,则无需担心:但是如果您要确保您拥有新模块,则:

$ sudo pip3 install --upgrade --force-reinstall pandas seaborn scipy numpy matplotlib tabulate networkx cython sklearn ipython

)

Step 5: Download the source code. 步骤5:下载源代码。 [I found this helped better than pip3: but if you want, do try the easy method '$sudo pip3 install networkit' first!] [我发现这比pip3更好:但是,如果您愿意,请先尝试使用简单的方法'$ sudo pip3 install networkit'!]

EITHER: Go to https://networkit.iti.kit.edu/get_started.html and scroll to "Build NetworKit from Source" and loop for the source code download
OR: just open https://networkit.iti.kit.edu/uploads/NetworKit.zip to download [works as of 13th Nov 2016]

(The download should take 2-5 minutes) (下载需要2-5分钟)

Step 6: Installing. 步骤6:安装。 (info based on tips from https://networkit.iti.kit.edu/get_started.html --> Build NetworKit from Source --> Building NetworKit) (信息基于https://networkit.iti.kit.edu/get_started.html- >从源代码构建NetworKit->构建NetworKit中的提示)

$ cd ~/Downloads
$ open NetworKit.zip #[if you need to unzip to source code]
$ cd NetworKit #[switch to the top folder of NetworKit]
$ sudo python3 setup.py build_ext --inplace #[run the script setup.py]

(Step 6 should take 5-10 minutes.) (第6步应花费5-10分钟。)

Step 7: See if it worked. 步骤7:查看是否有效。 Close the terminal again (eg click "Quit Terminal" or run "$ exit"). 再次关闭终端(例如,单击“退出终端”或运行“ $ exit”)。 Reopen and move back into your ~/Downloads/NetworKit directory. 重新打开并移至〜/ Downloads / NetworKit目录。 For example for me I have the following: 例如,我有以下内容:

$ python3
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.38)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import networkit
/usr/local/lib/python3.5/site-packages/IPython/html.py:14: ShimWarning: The `IPython.html` package has been deprecated. You should import from `notebook` instead. `IPython.html.widgets` has moved to `ipywidgets`.
  "`IPython.html.widgets` has moved to `ipywidgets`.", ShimWarning)
>>> G = networkit.Graph(5)
>>> G.addEdge(0,1)
<_NetworKit.Graph object at 0x11405f1b0>
>>> G.toString()
b'Graph(name=G#3, n=5, m=1)'
>>> G.nodes()
[0, 1, 2, 3, 4]
>>> G.edges()
[(1, 0)]
>>> G.neighbors(3)
[]
>>> from networkit.generators import BarabasiAlbertGenerator
>>> g = BarabasiAlbertGenerator(5, 50, 8).generate()
>>> g.nodes()
[0, 1, 2, ...., 49]
>>> g.neighbors(5)
[4, 6, 21, 31, 38, 47]  # Will probably be different for you.
>>> quit()
$ 

If everything seems to work above. 如果一切似乎都在上面。 Congratulations. 恭喜你 If not, I'm sorry.. it's not easy installing things like this! 如果没有,对不起..安装这样的东西并不容易! Hopefully some of the tips and tricks above will be useful in your final solution to how to install it. 希望上面的一些技巧对您的最终安装解决方案很有用。

Step 8: Confirm location. 步骤8:确认位置。 After step 7's success, I found that the module is not located properly. 成功执行第7步后,我发现该模块的位置不正确。 To see if you have the same problem, go to a new directory and repeat step 7. for example the following raises import errors for me: 要查看是否存在相同的问题,请转到新目录并重复步骤7。例如,以下内容对我造成了导入错误:

$ cd ~
$ python3
>>> import networkit
ImportErrors..

To fix this. 要解决此问题。 You need to move the whole NetworKit directory into a good location where python3 can find it. 您需要将整个NetworKit目录移动到python3可以找到它的好位置。 You might be able to move it to 您也许可以将其移至

/usr/local/lib/python3.5/site-packages/

which is one of the places where python3 looks for modules. 这是python3查找模块的地方之一。 If you do this method, you should add /usr/local/lib/python3.5/site-packages/networkit to the PYTHONPATH using: 如果执行此方法,则应使用以下命令将/usr/local/lib/python3.5/site-packages/networkit添加到PYTHONPATH中:

$ export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python3.5/site-packages/networkit  # To make this change permanent, add this line to your ~/.profile file. 

However my recommended method to do step 8 is the following: 但是,我推荐的执行步骤8的方法如下:

- $ mkdir ~/Documents/MyPython3Modules   # create a place to save your own built modules -- you can do this step with the Finder app too
- copy/drag the NetworKit folder (~/Downloads/NetworKit) to the new MyPython3Modules folder. I found this is easier with the Finder.
- edit your .profile file from the Terminal
~$ nano .profile  # or .bash_profile or whatever
##Add the following lines
export PYTHONPATH=$PYTHONPATH:~/Documents/MyPython3Modules  # Now any module import statements will look here too.
export PYTHONPATH=$PYTHONPATH:~/Documents/MyPython3Modules/NetworKit   
# or replace '~' with '/Users/GFenn' or whatever
$ 

(The reason for the second PYTHONPATH appendage is that NetworKit is a directory of stuff, with the actual networkit module inside it [and it calls objects in NetworKit so you can't just move networkit instead of the whole NetworKit]!) (第二个PYTHONPATH附件的原因是NetworKit是一个东西目录,其中包含实际的networkit模块[并且它调用NetworKit中的对象,因此您不能只移动networkit而不是整个NetworKit)!)

Step 9: confirm success. 步骤9:确认成功。 Close the Terminal again and reopen. 再次关闭终端,然后重新打开。 Go to a new directory away from Downloads and away from MyPython3Modules and see: 转到远离下载和MyPython3Modules的新目录,然后查看:

$ cd ~
$ cd Documents/Junk_dir  # Junk_dir is a boring folder in Documents
$ python3
>>> import networkit
/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/IPython/html.py:14: ShimWarning: The `IPython.html` package has been deprecated. You should import from `notebook` instead. `IPython.html.widgets` has moved to `ipywidgets`.
 "`IPython.html.widgets` has moved to `ipywidgets`.", ShimWarning)
>>> G = networkit.Graph(5)  # etc
>>> # all good
>>> quit()
$

Hopefully this guide helped. 希望本指南对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM