在Xcode中安装python3和beautifulsoup编码到M

2024-05-16 19:59:39 发布

您现在位置:Python中文网/ 问答频道 /正文

我从:https://stringpiggy.hpd.io/mac-osx-python3-dual-install/跟踪了这个url并检查了python版本。在

Python --version
>> Python 3.5.2

which python3
>> /Library/Frameworks/Python.framework/Versions/3.5/bin/python3

echo $PATH
>> /Library/Frameworks/Python.framework/Versions/3.5/bin:/usr/local/bin:/usr/local/Cellar/python3/3.5.2/bin:/usr/bin:/bin:/usr/sbin:/sbin

我用xcode编译代码,当我导入urllib并返回时

^{pr2}$

所以我认为pythonide是直接到机器的默认python 然后尝试python --version Python 2.7.10 如何使用Python3安装beauthoulsoup4.x

enter image description here

enter image description here

enter image description hereenter image description here


Tags: httpsiobinversionmacusrlocallibrary
1条回答
网友
1楼 · 发布于 2024-05-16 19:59:39

您已将脚本命名为python.py所以您看到错误的原因是:

padraic@home:~$ touch python.py
padraic@home:~$ echo "import urllib.request" > python.py 
padraic@home:~$ cat python.py 
import urllib.request
padraic@home:~$ python python.py 
Traceback (most recent call last):
  File "python.py", line 1, in <module>
    import urllib.request
ImportError: No module named request

重命名文件并删除目录中的所有.pyc文件。在

相关问题 更多 >