Windows 10 64位系统下如何安装PyYAML?现有方案均无效
Hey there, let's work through this PyYAML installation headache you're dealing with on Windows 10 64-bit! Multiple Python versions can definitely throw a wrench in things, so let's break down the fixes step by step:
Step 1: Make sure you're using the right pip for your target Python version
Since you have multiple Python installs (3.2 through 3.6), your pip3 command might be pointing to a different Python version than you think. To confirm:
- Open Command Prompt and run:
Check the output path—if it's not pointing to your Python 3.5 installation (e.g.,pip3 --versionC:\Python35\Scripts\pip.exe), you'll need to use the absolute path to the correct pip executable instead of justpip3. For example:C:\Python35\Scripts\pip.exe install --upgrade PyYAML
Step 2: Verify your wheel file matches your Python's exact ABI and architecture
The "wheel not supported on this platform" error usually means the wheel file you downloaded doesn't align with your Python's build details. For Python 3.5 on Windows 64-bit:
- Ensure the wheel filename follows the pattern
PyYAML-<version>-cp35-cp35m-win_amd64.whl—thecp35mpart is crucial (it indicates CPython 3.5 with pymalloc, which is standard for Windows builds). - If you tried a wheel without the
m(likecp35instead ofcp35m), that's likely the issue. Double-check the wheel you download matches your Python's exact tag—you can confirm your Python's tag by running this in a Python 3.5 shell:
For Python 3.5 64-bit Windows, this should outputimport sysconfig print(sysconfig.get_config_var('SOABI'))cp35-win_amd64orcp35m-win_amd64.
Step 3: Try installing without pre-built wheels (source installation)
If wheel files keep failing, you can force pip to install from source. Note: This might require having the Visual C++ Build Tools installed (for compiling the C extensions), but PyYAML also has a pure-Python fallback that should work even without build tools. Run:
C:\Python35\Scripts\pip.exe install --no-binary :all: PyYAML==3.12
Step 4: Clean up old installations first
Sometimes leftover partial installs can cause conflicts. Uninstall any existing PyYAML versions first to start fresh:
C:\Python35\Scripts\pip.exe uninstall -y PyYAML
Then retry the upgrade or wheel installation.
Quick Tip: Run Command Prompt as Administrator
Occasionally, permission issues can block pip from writing to Python's installation directory. Right-click Command Prompt and select "Run as administrator" before executing your install commands to rule this out.
内容的提问来源于stack exchange,提问作者Micoloth

