我分叉了一个Github仓库并且正在努力编译该项目。我正在使用Ubuntu并尝试使用setup.py文件进行安装,但我得到了这个:
$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'
我也尝试使用python 2进行编译。我使用了sudo apt-get install python-setuptools
然后当我尝试python setup.py install
时,我遇到一个问题,我认为这意味着我尝试编译的代码是python 3代码。问题是
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
我在Ubuntu终端上运行它。我想知道是否有人对我的情况有任何见解。谢谢!
答案 0 :(得分:1)
虚拟环境可能会解决这个问题。
sudo pip install virtualenv
virtualenv -p python3 myenv
source myenv/bin/activate
... do whatever you need to do.
答案 1 :(得分:0)
尝试直接从代码本身安装模块。
try:
import setuptools
except:
import os
os.system("pip install setuptools")
del os
答案 2 :(得分:0)
我最后重新编译了我的Python 3,它安装了最新版本的pip和setuptools并且工作正常。问题解决了!