问题是:
在macOS上。。。
已卸载Python3.6已重新安装Python3.7
卸载的Django 2尝试重新安装Django 2.1(失败)
我现在最大的问题是我不知道如何安装Django。
(
看看这篇文章的结尾,看看我能做的所有测试
)
笔记:
在学习了几个月的Python语法之后,我想扩展到创建一个非常基本的101 web应用程序。所以我开始学Django。我意识到我真的不知道那些移动的部分在哪里或者如何移动:pip、python、django、PyCharm、OS等等。。。一起工作,甚至在安装它们的地方。我从没听说过。。。包、包管理器、pip、路径或框架。所以,我决定尝试做一个深入的潜水,真正了解它是如何工作的。我最好的办法就是。。。把它全部解开,再把它放回原处。
问题和测试:
在终端:
python -m Django --version
结果:
/Library/Frameworks/Python.framework/Versions/3.7/bin/python3: No module named Django
可以。。。尝试安装Django:
pip install Django==2.1
结果:
Could not find a version that satisfies the requirement Django==2.1 (from versions: 1.1.3, [LARGE BLOCK OF VERSION NUMBERS, ALL IN RED] 1.11.15)
No matching distribution found for Django==2.1
试图弄清“路径”的真正含义:
>>> import sys
>>> for p in sys.path:
print(p)
结果:
/Users/MichaelPerkins/Documents
/Library/Frameworks/Pthon.framework/Versions/3.7/lib/python37.zip
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/lib-dynload
/Users/MichaelPerkins/Library/Python/3.7/lib/python/site-packages
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages
最后。。。只是想看看安装了什么,我输入了:
pip list
结果:
Package Version
-------------------------------------- --------
altgraph 0.10.2
bdist-mpkg 0.5.0
bonjour-py 0.3
macholib 1.5.1
matplotlib 1.3.1
modulegraph 0.10.4
numpy 1.8.0rc1
pip 18.0
py2app 0.7.3
pyobjc-core 2.5.1
pyobjc-framework-Accounts 2.5.1
pyobjc-framework-AddressBook 2.5.1
pyobjc-framework-AppleScriptKit 2.5.1
pyobjc-framework-AppleScriptObjC 2.5.1
pyobjc-framework-Automator 2.5.1
pyobjc-framework-CFNetwork 2.5.1
pyobjc-framework-Cocoa 2.5.1
pyobjc-framework-Collaboration 2.5.1
pyobjc-framework-CoreData 2.5.1
pyobjc-framework-CoreLocation 2.5.1
pyobjc-framework-CoreText 2.5.1
pyobjc-framework-DictionaryServices 2.5.1
pyobjc-framework-EventKit 2.5.1
pyobjc-framework-ExceptionHandling 2.5.1
pyobjc-framework-FSEvents 2.5.1
pyobjc-framework-InputMethodKit 2.5.1
pyobjc-framework-InstallerPlugins 2.5.1
pyobjc-framework-InstantMessage 2.5.1
pyobjc-framework-LatentSemanticMapping 2.5.1
pyobjc-framework-LaunchServices 2.5.1
pyobjc-framework-Message 2.5.1
pyobjc-framework-OpenDirectory 2.5.1
pyobjc-framework-PreferencePanes 2.5.1
pyobjc-framework-PubSub 2.5.1
pyobjc-framework-QTKit 2.5.1
pyobjc-framework-Quartz 2.5.1
pyobjc-framework-ScreenSaver 2.5.1
pyobjc-framework-ScriptingBridge 2.5.1
pyobjc-framework-SearchKit 2.5.1
pyobjc-framework-ServiceManagement 2.5.1
pyobjc-framework-Social 2.5.1
pyobjc-framework-SyncServices 2.5.1
pyobjc-framework-SystemConfiguration 2.5.1
pyobjc-framework-WebKit 2.5.1
pyOpenSSL 0.13.1
pyparsing 2.0.1
python-dateutil 1.5
pytz 2013.7
scipy 0.13.0b1
setuptools 18.5
six 1.4.1
xattr 0.6.4
zope.interface 4.1.1
在PyCharm中:
当我打开我在这些卸载/重新安装之前创建的一个项目,并尝试运行一个新的或现有的.pY文件时,我得到…
"/Users/MichaelPerkins/Library/Mobile Documents/com~apple~CloudDocs/Python Projects/BlackJack/venv/bin/python" "/Applications/PyCharm CE.app/Contents/helpers/pydev/pydevconsole.py" 59523 59524
dyld: Library not loaded: /Library/Frameworks/Python.framework/Versions/3.6/Python
Referenced from: /Users/MichaelPerkins/Library/Mobile Documents/com~apple~CloudDocs/Python Projects/BlackJack/venv/bin/python
Reason: image not found
Process finished with exit code 134 (interrupted by signal 6: SIGABRT)
然而,当我创建一个新项目时,它会使用Python 3.7的新版本。
import(sys)
print(sys.version)
结果:
/Users/MichaelPerkins/Projects/Test_1/venv/bin/python /Users/MichaelPerkins/Projects/Test_1/version.py
3.7.0 (v3.7.0:1bf9cc5093, Jun 26 2018, 23:26:24)
[Clang 6.0 (clang-600.0.57)]
Process finished with exit code 0