Python 2.7可正常导入TensorFlow,Python 3.6.4导入时报错求助
Hey there! Let's work through this TensorFlow import problem you're facing with Python 3.6.4. Since your Python 2.7 setup works perfectly, the issue is almost definitely tied to version mismatches or a wonky installation in your Anaconda Python 3.6 environment. Here are the actionable steps to fix it:
1. Install a TensorFlow version compatible with Python 3.6.4
TensorFlow drops support for older Python versions in newer releases. For Python 3.6.4, TensorFlow 1.15.x is the latest major release that supports it (TensorFlow 2.x phased out Python 3.6 support after early versions). Install the compatible version with:
# Using pip pip install tensorflow==1.15.5 # Or if you prefer Conda conda install tensorflow=1.15.5
2. Confirm you're using the correct Python 3.6 environment
It's easy to accidentally run commands in the wrong environment. Double-check which Python you're using:
python --version which python
If the path doesn't point to your Anaconda 3.6 environment (like /root/anaconda3/bin/python), activate the right environment first:
source activate your_python36_env_name
3. Reinstall TensorFlow to fix corrupted files
Corrupted installation files are a common culprit for pywrap_tensorflow errors. Uninstall the existing version and do a fresh install:
pip uninstall tensorflow -y pip install tensorflow==1.15.5 --no-cache-dir
The --no-cache-dir flag ensures you're downloading a clean copy instead of using broken cached files.
4. Install missing system dependencies
The pywrap_tensorflow error often pops up when required system libraries are missing. For Linux systems, install these core dependencies:
# For Debian/Ubuntu-based distros sudo apt-get install libcupti-dev libcudnn7 libcudnn7-dev # For CentOS/RHEL-based distros sudo yum install libcupti-devel libcudnn7 libcudnn7-devel
5. Check GPU compatibility (if using GPU-enabled TensorFlow)
If you're using the GPU version, make sure your CUDA and cuDNN versions match TensorFlow 1.15.x's requirements:
- CUDA 10.0
- cuDNN 7.6
If you still hit the error after trying these steps, sharing the full, uncut traceback would help pinpoint the exact issue—since your original error message got truncated.
内容的提问来源于stack exchange,提问作者Fayas B.

