简体   繁体   中英

unable to import pyglet when “installed”

complete python (and programming) beginner here. I am trying to install and import the pyglet module on my mac. I initially installed it using pip, and it seemed to work, at least I got no errors returned, but when I try to import it using pycharm I get:

Traceback (most recent call last):   File "/Users/me/PycharmProjects/Training/Training File.py", line 1, in <module>
    import pyglet ModuleNotFoundError: No module named 'pyglet'

When I tried to install it again, after getting this error, I get this from the command line:

MacBook:bin me$ python -m pip install pyglet Requirement already satisfied: pyglet in /Library/Python/2.7/site-packages MacBook:bin me$

So it seems it's already installed, no?

Finally, I tried to install it using the setup.py command, which was the recommendation in the README file. I get this:

MacBook:~ me$ sudo python setup.py install  python: can't open file 'setup.py': [Errno 2] No such file or directory MacBook:~ me$

Can anyone tell what is going on?

您可以在python 3中运行脚本。但是您已经为python 2安装了pyglet。

pip3 install pyglet 

I think it worked! I used

python3 -m pip install python

Thanks!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM