重庆市建筑网站建设/百度首页精简版
1.sublime要保存文件后才能运行,文件名后缀自己加.py
2.
《解决pycharm问题:module 'pip' has no attribute 'main'》
更新pip之后,Pycharm安装package出现报错:module 'pip' has no attribute 'main'
找到【pycharm】安装目录下 helpers/packaging_tool.py文件,找到如下代码:
def do_install(pkgs):
try:
import pip
except ImportError:
error_no_pip()
return pip.main(['install'] + pkgs)
def do_uninstall(pkgs):
try:
import pip
except ImportError:
error_no_pip()
return pip.main(['uninstall', '-y'] + pkgs)
修改为如下,保存即可。
def do_install(pkgs):
try:
# import pip
try:
from pip._internal import main
except Exception:
from pip import main
except ImportError:
error_no_pip()
return main(['install'] + pkgs)
def do_uninstall(pkgs):
try:
# import pip
try:
from pip._internal import main
except Exception:
from pip import main
except ImportError:
error_no_pip()
return main(['uninstall', '-y'] + pkgs)
3. 举个例子:
pip install numpy -i https://pypi.tuna.tsinghua.edu.cn/simple
4.Mac
出现中文的话有错误:
SyntaxError: Non-ASCII character '\xe4' in file a6.py on line 2, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
解决方法:前面加
# -*- coding: utf-8 -*
5.python3.x版本使用web.py,cmd输入:
pip install web.py==0.40.dev0
安装完成后import web即可
5、解决python 提示 SyntaxError: Missing parentheses in call to 'print'
因为python2.X版本与python3.X版本输出方式不同造成的。在python3.X输入内容时要带上括号python(),而在2.X可以直接输出。
6、 the imp module is deprecated in favour of importlib...
解决方法:前面加import imp。
7、Pycharm在运行过程中,查看每个变量的方法(show variables)
https://blog.csdn.net/qq_15969343/article/details/79895761
8、Expected 2D array, got 1D array instead:
解决方法:
age_scale_param = scaler.fit(df['Age'].values.reshape(-1,1))
df['Age_scaled'] = scaler.fit_transform(df['Age'].values.reshape(-1,1), age_scale_param)
fare_scale_param = scaler.fit(df['Fare'].values.reshape(-1,1))
df['Fare_scaled'] = scaler.fit_transform(df['Fare'].values.reshape(-1,1), fare_scale_param)
9、警告:Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
解决方法:
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
10、pip install 从 github 安装
pip3 install git+https://github.com/nlpAThits/WOMBAT.git@master