I use a DigitalOcean server running Ubuntu 16.04, and I have used networkx before with Python3. But when I tried to import networkx today, I received a syntax error.
$ python3
Python 3.5.2 (default, Oct 7 2020, 17:19:02)
[GCC 5.4.0 --------] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> import networkx as nx
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/dist-packages/networkx/__init__.py", line 23
f"{release.authors['Hagberg'][0]} <{release.authors['Hagberg'][1]}>\n"
^
SyntaxError: invalid syntax
I also tried to uninstall and reinstall networkx, but I now get other syntax errors.
$ sudo pip3 uninstall networkx
Traceback (most recent call last):
File "/usr/local/bin/pip3", line 7, in <module>
from pip._internal.cli.main import main
File "/usr/local/lib/python3.5/dist-packages/pip/_internal/cli/main.py", line 60
sys.stderr.write(f"ERROR: {exc}")
^
SyntaxError: invalid syntax
... on the attempt at install :
$ sudo pip3 install networkx
Traceback (most recent call last):
File "/usr/local/bin/pip3", line 7, in <module>
from pip._internal.cli.main import main
File "/usr/local/lib/python3.5/dist-packages/pip/_internal/cli/main.py", line 60
sys.stderr.write(f"ERROR: {exc}")
^
SyntaxError: invalid syntax
I researched online, and I saw that I needed to do updates, which I ran.
sudo apt update
sudo apt upgrade
sudo apt-get install python3-pip python3-dev
But these errors continue. Is there a dependency file I need to go in and manually change to Python3.5 ? I saw that somewhere. It feels like this is a stupid problem, and these are the kinds that always trip me up. Any help would be greatly appreciated. Thank you.