I'm trying to run the TSP in NetworkX, and I'm following their code from https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.approximation.traveling_salesman.traveling_salesman_problem.html
However, whenever I try to import the module, it gives me an error.
For example:
import networkx.approximation as na
gives the error
ModuleNotFoundError: No module named 'networkx.approximation'
And
import networkx.algorithms.approximation as naa
tsp = naa.traveling_salesman_problem
Gives the following error:
AttributeError: module 'networkx.algorithms.approximation' has no attribute 'traveling_salesman_problem'
I'm copying the code directly from the manual so I'm not sure what I'm doing wrong.
Someone who understands pip better may please jump in here.
I had the same errors as you mentioned and checked my version of networkx (which was 2.5.2) and apperantly the TSP part was added later. The current version mentioned on their website is 2.6.2. Through pip install networkx only 2.5.2 was installed. But with pip install --upgrade networkx[default] it upgraded to 2.6.2 and the the commands work.
Related
I am trying to import Pennylane in jupyter notebook. I installed it using Ubuntu.
import pennylane as cents
However, it is spewing out this:
ImportError: cannot import name 'shape'
I found two reasons online. One is that python needs to be at version less than 3.7[https://github.com/PennyLaneAI/pennylane/issues/1922]. To solve this I used pip install -U jupyter. Another reason is that Pennylane might be at a version earlier enough that it had a bug[https://discuss.pennylane.ai/t/importerror-cannot-import-name-shape/1383]. I installed Pennylane to the latest version I could find, 0.25. I did pip install pennylane==0.25 But it still does not work
Could someone please explain this to me?
When I am trying to import matlibplot or sns or plotly packages below is the error
AttributeError: module 'matplotlib.dates' has no attribute '_rcParam_helper'.
I have tried to install older versions but no luck.
I suspect that this is an installation issue where you have more than one version of Matplotlib installed at the same time so some files are from one version and some are from another (a chimera).
I suggest uninstalling everything and starting again clean with exactly one package management tool (pip vs conda vs system vs ...).
In https://github.com/matplotlib/matplotlib/commit/814a969d4a731321827a108c38ed6f3aaf50a623 (which looks like it went in between 3.4.2 and 3.5.0) we re-named an internal class. I suspect you have a new version of dates.py and an old version of rcsetup.py.
Open3d was not available on the anaconda navigator so I installed it using the anaconda prompt with the conda install command.
I wanted to try a basic code for Ball Pivoting Algorithm from http://www.open3d.org/docs/release/tutorial/geometry/surface_reconstruction.html
import open3d as o3d
import os
import sys
bunny = o3d.data.BunnyMesh()
gt_mesh = o3d.io.read_triangle_mesh(bunny.path)
gt_mesh.compute_vertex_normals()
but even running the first lines I get the error
Attribute error: module ‘open3d’ has no attribute ‘data’
I’ve no idea why this is.
Support for open3d.data has been added in version 0.15. Upgrade the Open3d version and then try this API.
Release note: https://github.com/isl-org/Open3D/releases/tag/v0.15.1
I've been struggling for hours on a problem that is making me insane. I installed Python 2.7 with Cygwin and added Scipy, Numpy, Matplotlib (1.4.3) and Ipython. When I decided to run ipython --pylab I get the following error:
/usr/lib/python2.7/site-packages/matplotlib/transforms.py in <module>()
37 import numpy as np
38 from numpy import ma
----> 39 from matplotlib._path import (affine_transform, count_bboxes_overlapping_bbox,
40 update_path_extents)
41 from numpy.linalg import inv
ImportError: No module named _path
I spent hours on the internet, looking for a solution but nothing worked. I did notice that I am missing _path.so files in the matplotlib directory that everybody seems to have. Instead, I have two files: path.py and path.pyc. But I installed matplotlib directly from the official website using pip install and reinstalling it didn't make any difference. Does anyone have a little clue on what is going wrong? I would be incredibly grateful !!!
For others having this problem, in my case, the solution was simple. The problem was caused by having the wrong matplot library installed on your computer; creating an error in finding the correct matplotlib path. In my case, I had installed matplotlib on a different version of python. Simply update matplotlib on your computer, so that it is compatible with your current version of python:
pip install --upgrade matplotlib
As for the post, I am unsure of what caused these big issues. Hope my tip can help anyone else stumbling upon this issue!
I doubt that most of you brought here by Google have the problem I had, but just in case:
I got the above "ImportError: No module named _path" (on Fedora 17) because I was trying to make use of matplotlib by just setting sys.path to point to where I had built the latest version (1.5.1 at the time). Don't do that.
Once I ran "python setup.py install" (as root) to do a proper install (and got rid of my sys.path hack), the error was fixed.
The package matplotlib requires multiple dependencies (see them here). For me, the missing dependencies included pyparsing and kiwisolver, but your results my vary. Before you do any of these other things (reinstalling python or the library, etc...), make sure you have installed (pip install ...) all the libs in this list (link).
I am trying to download the Pygraphics module using Python 2.7.6 and have been heretofore unsuccessful. Below I detail the steps I have taken so far. Any help with this would be most appreciated.
First, I tried the typical install using pip
sudo pip install Pygraphics
When I try to import the module, I receive an error saying ImportError: No module named Pygraphics.
To test whether the module was installed I ran the following code: print sorted(["%s==%s" % (i.key, i.version) for i in pip.get_installed_distributions()]) which showed me all of my installed distributions.
This code returned the following list of all the distributions and clearly showed that Pygraphics is installed:
['altgraph==0.10.2', 'bdist-mpkg==0.5.0', 'bonjour-py==0.3', 'brewer2mpl==1.4', 'certifi==14.05.14', 'datetime==4.0.1', 'flask==0.10.1', 'ggplot==0.6.5', 'ipython==2.0.0-dev', 'itsdangerous==0.24', 'jdcal==1.0', 'jinja2==2.7.3', 'macholib==1.5.1', 'markupsafe==0.23', 'matplotlib==1.4.x', 'mock==1.0.1', 'modulegraph==0.10.4', 'nose==1.3.4', 'numpy==1.9.0.dev-297f54b', 'openpyxl==2.1.2', 'pandas==0.14.1', 'pandasql==0.6.1', 'patsy==0.3.0', 'pika==0.9.14', 'py2app==0.7.3', 'pygments==1.6', 'pygraphics==2.1']
After this, I tried using the GUI installer located on the following Pygrahpics install website. While going through the installer, I received an error message saying "PyGraphics requires System Python 2.7 to install" despite the fact that I have downloaded Python 2.7.6.
At this point I don't know what to do and was hoping someone who may have had a similar issue might be able to help me out.
Thank you for your time.
It looks like you've successfully install PyGraphics. Now import picture :)