[英]Installing python3 and beautifulsoup coding in Xcode to Mac
I followed this url from: https://stringpiggy.hpd.io/mac-osx-python3-dual-install/ and checked python version. 我跟着这个网址: https : //stringpiggy.hpd.io/mac-osx-python3-dual-install/并检查了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
I used xcode to compile my code, when I import urllib and return, 我使用xcode编译我的代码,当我导入urllib并返回时,
Traceback (most recent call last):
File "python.py", line 21, in <module>
import urllib.request
ImportError: No module named request
Program ended with exit code: 1
So I think python IDE is direct to machine default python and try python --version
Python 2.7.10 How can I use Python3 to install beautifulsoup 4.x 所以我认为python IDE直接用于机器默认python并尝试
python --version
Python 2.7.10如何使用Python3安装beautifulsoup 4.x
You have named your script python.py so that is why you are seeing the error: 您已将脚本命名为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
Rename your file and delete any .pyc files in the directory. 重命名文件并删除目录中的任何.pyc文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.