Jonathan L Walsh
Jonathan L Walsh

Reputation: 1

Python 3 can't find setuptools module - Ubuntu

I forked a Github repo and am struggling to compile the project. I am using Ubuntu and am trying to install using the setup.py file but I get this:

$sudo apt-get install python3-setuptools
  Reading package lists... Done
  Building dependency tree
  Reading state information... Done
  python3-setuptools is already the newest version (20.7.0-1)
  0 upgraded, 0 newly installed, 0 to remove, and 100 not upgraded.
$python3 setup.py install
  Traceback (most recent call last):
    File "setup.py", line 5, in <module>
      from setuptools import setup, find_packages
  ModuleNotFoundError: No module named 'setuptools'

I've also tried compiling with python 2. I used sudo apt-get install python-setuptools and then when I try python setup.py install I get an issue that I think means that the code I am trying to compile is python 3 code. The issue is

File "/usr/local/lib/python2.7/dist-packages/pokemon_terminal-0.0.1-py2.7.egg/pokemonterminal/database.py", line 101
def get_pokemon_of_type(self, pkmn_type: str, single: bool = True):
                                       ^
SyntaxError: invalid syntax

I am running this in an Ubuntu terminal. I was wondering if anyone had any insight on my situation. Thanks!

Upvotes: 0

Views: 2652

Answers (3)

Jonathan L Walsh
Jonathan L Walsh

Reputation: 1

I ended up recompiling my Python 3 and it installed the newest version of pip and setuptools and worked. Problem solved!

Upvotes: 0

Alex
Alex

Reputation: 1262

Probably a virtual enviroment will fix this.

sudo pip install virtualenv
virtualenv -p python3 myenv
source myenv/bin/activate
... do whatever you need to do.

Upvotes: 1

Yuval Meshorer
Yuval Meshorer

Reputation: 166

Try installing the module straight from the code itself.

try:
    import setuptools
except:
    import os
    os.system("pip install setuptools")
    del os

Upvotes: 0

Related Questions