I want to use the Algorithms inside of the cdlib library for network analysis. I installed cdlib by:
pip install cdlib
However I am unable to check the version of the same library using
cdlib --version
which gives me an error, saying:
zsh: command not found: cdlib
Moreover, upon using
from cdlib import algorithms
--------------------------------------------------------------------------- ImportError Traceback (most recent call
last)
/var/folders/gm/d0bzgb6n4k95px0_1x9hqq_h0000gn/T/ipykernel_43989/3546710294.py
in
----> 1 from cdlib import algorithms
2 import networkx as nx
~/opt/anaconda3/lib/python3.9/site-packages/cdlib/algorithms/init.py
in
1 from .edge_clustering import *
----> 2 from .crisp_partition import *
3 from .overlapping_partition import *
4 from .attribute_clustering import *
5 from .bipartite_clustering import *
~/opt/anaconda3/lib/python3.9/site-packages/cdlib/algorithms/crisp_partition.py
in
52
53 try:
---> 54 import infomap as imp
55 except ModuleNotFoundError:
56 missing_packages.add("infomap")
~/opt/anaconda3/lib/python3.9/site-packages/infomap.py in
36 from . import _infomap
37 else:
---> 38 import _infomap
39
40 try:
ImportError:
dlopen(/Users/hrisod/opt/anaconda3/lib/python3.9/site-packages/_infomap.cpython-39-darwin.so,
0x0002): Library not loaded: /usr/local/opt/llvm/lib/libomp.dylib
Referenced from:
/Users/hrisod/opt/anaconda3/lib/python3.9/site-packages/_infomap.cpython-39-darwin.so
Reason: tried: '/usr/local/opt/llvm/lib/libomp.dylib' (no such file),
'/usr/local/lib/libomp.dylib' (no such file), '/usr/lib/libomp.dylib'
(no such file)
This error is found. I tried reinstalling the same library even using the ways in the documentation, all too no avail.
I am using jupyter notebook on mac for this project.
Can someone please help me find out how to properly download the library.
Reading your error more thoroughly, you'll note that it says 54 import infomap as imp 55 except ModuleNotFoundError: 56 missing_packages.add("infomap"). (Seems to relate to this. this bug report, and here. Since you are on a Mac, is this pertnent ==> here?)
I note you are using conda but trying to install cldlib with pip. This says maybe trying strictly with cdlib from conda may help. Uninstall via pip maybe first, using python -m pip uninstall cdlib, before trying conda.
If you want to try dealing with the infomap stuff first though ...
Since you are using conda, you should try using Anaconda that to install infomap. If you just care about using it in this notebook, you can try that with %conda install -c conda-forge infomap in a cell in the notebook.
Related
I am running a Python package called pymatgen in Jupyter. Jupyter and pymatgen are installed in a conda environment. I have manually installed ruamel using conda's python3, but the same error occurs. The strange thing is that the same code (in this case just a library load statement) gives no errors when run with ipython. Both Jupyter and ipython are running from the miniconda installation (I check with the command which). I noticed some postings on the web stating that ruamel has problems with conda due to the remapping of a "." to an underscore character, but none of the proposed solutions helped the above problem. I also don't understand why ipython is fine and Jupyter fails. Any suggestions?
from pymatgen.core.structure import Structure, Lattice
from pymatgen.core.periodic_table import Element
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-753da7cc5963> in <module>
----> 1 from pymatgen.core.structure import Structure, Lattice
2 from pymatgen.core.periodic_table import Element
~/.local/lib/python3.7/site-packages/pymatgen/__init__.py in <module>
13 import os
14 import warnings
---> 15 import ruamel.yaml as yaml
16 from fnmatch import fnmatch
17
ModuleNotFoundError: No module named 'ruamel'
Use the below command to install it:
pip install ruamel.yaml
When I call:
import pandas as pd
on tensorflow_macos (for M1 chip)
I get:
ImportError Traceback (most recent call last)
~/tensorflow_macos_venv/lib/python3.8/site-packages/pandas/__init__.py in <module>
28 try:
---> 29 from pandas._libs import hashtable as _hashtable, lib as _lib, tslib as _tslib
30 except ImportError as e: # pragma: no cover
~/tensorflow_macos_venv/lib/python3.8/site-packages/pandas/_libs/__init__.py in <module>
12
---> 13 from pandas._libs.interval import Interval
14 from pandas._libs.tslibs import (
ImportError: dlopen(/Users/ashkan/tensorflow_macos_venv/lib/python3.8/site-packages/pandas/_libs/interval.cpython-38-darwin.so, 2): no suitable image found. Did find:
/Users/ashkan/tensorflow_macos_venv/lib/python3.8/site-packages/pandas/_libs/interval.cpython-38-darwin.so: mach-o, but wrong architecture
/Users/ashkan/tensorflow_macos_venv/lib/python3.8/site-packages/pandas/_libs/interval.cpython-38-darwin.so: mach-o, but wrong architecture
The above exception was the direct cause of the following exception:
ImportError Traceback (most recent call last)
<ipython-input-3-94f55571b0d6> in <module>
1 import numpy as np
----> 2 import pandas as pd
3
4 import matplotlib.pyplot as plt
5
~/tensorflow_macos_venv/lib/python3.8/site-packages/pandas/__init__.py in <module>
31 # hack but overkill to use re
32 module = str(e).replace("cannot import name ", "")
---> 33 raise ImportError(
34 f"C extension: {module} not built. If you want to import "
35 "pandas from the source directory, you may need to run "
ImportError: C extension: dlopen(/Users/ashkan/tensorflow_macos_venv/lib/python3.8/site-packages/pandas/_libs/interval.cpython-38-darwin.so, 2): no suitable image found. Did find:
/Users/ashkan/tensorflow_macos_venv/lib/python3.8/site-packages/pandas/_libs/interval.cpython-38-darwin.so: mach-o, but wrong architecture
/Users/ashkan/tensorflow_macos_venv/lib/python3.8/site-packages/pandas/_libs/interval.cpython-38-darwin.so: mach-o, but wrong architecture not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --force' to build the C extensions first.
I hope Xcode Command Line Tools is already installed. If not, please install it then follow the steps.
Step 1:miniforge
Install miniforge for arm64 (Apple Silicon) from miniforge GitHub. Miniforge enables installing python packages natively compiled for Apple Silicon.
Step 2: create Conda environment
Don’t forget to open a new session or to source your .zshrc after miniforge install and before going through this step.
Create an empty Conda environment, then activate it and install python 3.8. and all the needed packages. Please note numpy is unnecessary here as pandas already install it, but it will be overwritten in the last step with the version provided by Apple.
conda create --name mytf
conda activate mytf
conda install -y python==3.8.6
conda install -y pandas matplotlib scikit-learn jupyterlab
I have tested it. It will work after these steps.
As shown in the next post(https://github.com/apple/tensorflow_macos/issues/6), it seems that the solution is to install pandas from conda until they fix this problem.
To install pandas:
conda install pandas
Or installing directly from the source:
https://github.com/pandas-dev/pandas#installation-from-sources
Follow these steps -
Important With Tensorflow Installation
With miniforge installation do this -
conda install numpy scipy scikit-learn pandas matplotlib seaborn
Use Anaconda visual UI to install into the conda environment you created. You just select your environment and search for pandas.
I was using Jupyter Notebook to do some studying today and noticed that I couldn't import Tensorflow or Keras. It was strange because until yesterday it was working fine. Anyway, I looked online and some people recommended I install Jupyter again using conda install jupyter notebook. I did exactly that and now I can't even import Tensorflow or NumPy. Not to mention whenever I try to open Jupyter that doesn't work either. I see a command prompt flash briefly and then nothing happens.
When I try to import either, I get this error:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
~\Anaconda3\lib\site-packages\numpy\core\__init__.py in <module>
39 try:
---> 40 from . import multiarray
41 except ImportError as exc:
~\Anaconda3\lib\site-packages\numpy\core\multiarray.py in <module>
11
---> 12 from . import overrides
13 from . import _multiarray_umath
~\Anaconda3\lib\site-packages\numpy\core\overrides.py in <module>
5
----> 6 from numpy.core._multiarray_umath import (
7 add_docstring, implement_array_function, _get_implementing_args)
ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
<ipython-input-1-0aa0b027fcb6> in <module>
----> 1 import numpy as np
~\Anaconda3\lib\site-packages\numpy\__init__.py in <module>
140 from . import _distributor_init
141
--> 142 from . import core
143 from .core import *
144 from . import compat
~\Anaconda3\lib\site-packages\numpy\core\__init__.py in <module>
69 Original error was: %s
70 """ % (sys.executable, exc)
---> 71 raise ImportError(msg)
72 finally:
73 for envkey in env_added:
ImportError:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the multiarray numpy extension module failed. Most
likely you are trying to import a failed build of numpy.
Here is how to proceed:
- If you're working with a numpy git repository, try `git clean -xdf`
(removes all files not under version control) and rebuild numpy.
- If you are simply trying to use the numpy version that you have installed:
your installation is broken - please reinstall numpy.
- If you have already reinstalled and that did not fix the problem, then:
1. Check that you are using the Python you expect (you're using
C:\Users\seant\Anaconda3\python.exe),
and that you have no directories in your PATH or PYTHONPATH that can
interfere with the Python and numpy versions you're trying to use.
2. If (1) looks fine, you can open a new issue at
https://github.com/numpy/numpy/issues. Please include details on:
- how you installed Python
- how you installed numpy
- your operating system
- whether or not you have multiple versions of Python installed
- if you built from source, your compiler versions and ideally a build log
Note: this error has many possible causes, so please don't comment on
an existing issue about this - open a new one instead.
Original error was: No module named 'numpy.core._multiarray_umath'
I tried reinstalling NumPy, but that didn't solve the issue. I installed Python and NumPy via installing Anaconda, and my operating system is Windows 10. My path variable looked normal as well and everything was working until now. Does anyone know how I can proceed to fix this issue?
Go to your terminal and locate the environment where you have Numpy and the other modules installed. If your'e using virtualenvwrapper you can run:
lsvirtualenv a list of your virtual envs you have will be displayed.
Then type workon virtualenv1 (replace with name of displayed virtual env) and check for your installed modules e.g after selecting the virtual env you can then type
python and get into the shell. Then you can do import numpy etc to check if the modules youre looking for exist in that virtualenv. When you find them you can then exit out of the shell and do a pip install jupyter to install jupyter notebooks on the virtual env with the modules you need. To avoid meeting such problems in future you should make sure you maintain virtual environments in your machine with the modules that your're interested to work with as per virtual env. Virtualenvwrapper is a great tool that abstracts away most of the common pitfalls found with working with virtual envs. More info in managing and creating virtual envs can be found here.
In my case I just spent around an hour uninstalling everything Python-related (Python, Anaconda, etc.) and completely installing everything from scratch again. It was a bit of a pain but I didn't know what else to do without having to dive too deeply into the issue.
Following the Udacity course on Deep Learning with TensorFlow, and hit a roadblock here: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/examples/udacity/1_notmnist.ipynb
I tried to get the installation running, but the initial imports didn't work out so well. Specifically, this import error on a certain file:
/tensorflow/lib/python2.7/site-packages/sklearn/linear_model/cd_fast.so
Running tensorflow in a virtualenv installation on Ubuntu 14.04, should that help.
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-3-72264e7a4df2> in <module>()
9 from IPython.display import display, Image
10 from scipy import ndimage
---> 11 from sklearn.linear_model import LogisticRegression
12 from six.moves.urllib.request import urlretrieve
13 from six.moves import cPickle as pickle
.../tensorflow/lib/python2.7/site-packages/sklearn/linear_model/__init__.py in <module>()
15 from .least_angle import (Lars, LassoLars, lars_path, LarsCV, LassoLarsCV,
16 LassoLarsIC)
---> 17 from .coordinate_descent import (Lasso, ElasticNet, LassoCV, ElasticNetCV,
18 lasso_path, enet_path, MultiTaskLasso,
19 MultiTaskElasticNet, MultiTaskElasticNetCV,
.../tensorflow/lib/python2.7/site-packages/sklearn/linear_model/coordinate_descent.py in <module>()
27 from ..utils import ConvergenceWarning
28
---> 29 from . import cd_fast
30
31
ImportError: .../tensorflow/lib/python2.7/site-packages/sklearn/linear_model/cd_fast.so: undefined symbol: PyFPE_jbuf
Anyone here who knows how to proceed? (Maybe this is a very simple error - I'm quite the newbie to this)
UPDATE:
Everything works fine when I run the iPython Notebooks from the usual terminal, as opposed to running them from the tensorflow virtual environment (as I had done when I first posted this question). I do not understand why this happened, though.
I also had trouble with sklearn in working with tensor flow. I had dowload it and install latest version manually to the TSNE module to work. Perhaps this will work for you too?
Step 1: Install Cython manually - you will version > 0.21
mkdir cython
cd cython
wget http://cython.org/release/Cython-0.24.zip
unzip Cython-0.24.zip
cd Cython-0.24
sudo python setup.py install
Step 2: Install latest version of skilearn
I currently have an anaconda installation of of Python, which includes astropy and numpy among other useful packages. I recently updated my Astropy individually through pip, by running
pip install --upgrade astropy
After this silly thing that I probably should not have done (I should have upgrades the entire anaconda package), my pyspeckit package stopped working, claiming it could not find the version.py in astropy.
This is the error I get:
/Users/saracamnasio/Research/code/MC_test.py in <module>()
5 import utilities as u
6 import BDdb
----> 7 import pyspeckit
8 import StringIO
9 import corner
/Users/saracamnasio/Research/code/pyspeckit/pyspeckit/__init__.py in <module>()
8
9 if not _ASTROPY_SETUP_:
---> 10 from version import version as __version__
11 import spectrum
12 import specwarnings
ImportError: No module named version
I tried to uninstall and reinstall astropy, as well as update anaconda independently but it's not working to fix it. Suggestions?
Evert's comment is most likely the correct answer: just update pyspeckit. The version you're using is out of date and has some potential inconsistencies in how it does relative imports.
However, what you have uncovered is, if not a bug, definitely not a feature, so it will be removed soon:
https://github.com/pyspeckit/pyspeckit/pull/134