我最近从Enthought Canopy切换到Anaconda,并使用Spyder IDE.我注意到当我绘制一些数据时,
import matplotlib.pyplot as plt
plt.figure()
plt.plot(rigs2)
plt.ion()
plt.show()
Run Code Online (Sandbox Code Playgroud)
它在IPython控制台中显示为内联图:
但是,在Enthought中,情节会出现在一个带有缩放,后退和前进按钮的单独窗口中.Spyder有没有办法实现同样的目标?
我正在尝试将生产数据库恢复到本地计算机,类似于 Heroku ( https://devcenter.heroku.com/articles/heroku-postgres-import-export ) 描述的工作流程。不过,我正在使用 Aptible,它为此目的提供了一个数据库隧道。
使用 pgAdmin4,我创建了一个“自定义”备份。然后,稍微修改 pgAdmin 命令,我使用以下命令恢复了它
"/Applications/pgAdmin 4.app/Contents/SharedSupport/pg_restore" --host "localhost" --port "5432" --username "postgres" --no-password --dbname "lucy_prod" --verbose "/Users/kurtpeek/lucy-prod-backup-11-june-2018" --clean
Run Code Online (Sandbox Code Playgroud)
我在其中添加了--clean在重新创建数据库对象之前删除它们的选项(参见https://www.postgresql.org/docs/9.2/static/app-pgrestore.html)。
问题是,当我现在尝试时python manage.py migrate,出现以下错误:
(venv) Kurts-MacBook-Pro-2:lucy-web kurtpeek$ python manage.py migrate
Traceback (most recent call last):
File "/Users/kurtpeek/Documents/Dev/lucy2/lucy-web/venv/lib/python3.6/site-packages/django/db/backends/utils.py", line 62, in execute
return self.cursor.execute(sql)
psycopg2.ProgrammingError: no schema has been selected to create in
LINE 1: CREATE TABLE "django_migrations" ("id" serial NOT NULL PRIMA...
^
The above exception was the …Run Code Online (Sandbox Code Playgroud) 调整来自https://github.com/bluejeans/api-rest-meetings/tree/master/libs/python#pip-install的说明,pipenv shell我试图运行
pipenv install git+https://github.com/bluejeans/api-rest-meetings.git@pip-repo
Run Code Online (Sandbox Code Playgroud)
但是,我收到以下错误消息:
⠋警告:pipenv需要#egg片段来控制版本控制的依赖项.请以git + https://github.com/bluejeans/api-rest-meetings.git#egg=的形式安装远程依赖项.
这是完整的命令和响应:
(lucy-web-CVxkrCFK) bash-3.2$ pipenv install git+https://github.com/bluejeans/api-rest-meetings.git@pip-repo
Installing git+https://github.com/bluejeans/api-rest-meetings.git@pip-repo...
?WARNING: pipenv requires an #egg fragment for version controlled dependencies. Please install remote dependency in the form git+https://github.com/bluejeans/api-rest-meetings.git#egg=<package-name>.
ABORTING INSTALL... You will have to reinstall any packages that failed to install.
You may have to manually run pipenv lock when you are finished.
Run Code Online (Sandbox Code Playgroud)
我如何获得egg此套餐?或者甚至更好,我怎么能不能指定一个鸡蛋?
我正在尝试理解以下代码片段:
class Config(dict):
def __init__(self):
self.__dict__ = self
Run Code Online (Sandbox Code Playgroud)
这条线的目的是self.__dict__ = self什么?我想它会__dict__使用简单地返回对象本身的东西来覆盖默认函数,但是由于Config从dictI 继承而无法找到与默认行为的任何差异.
我已经实现了Floyd Warshall算法并且它可以工作,但问题是我不知道如何找到所有未定义的路径.我在网上搜索过,但我只能找到如何检测图表是否有负循环的答案.
vector< vector <int> > floyd_warshall(vector< vector<int> > d, int n){
for(int i = 0; i < n; i++) d[i][i] = 0;
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
for(int k = 0; k < n; k++){
if(d[j][i] + d[i][k] < d[j][k] and d[j][i] != INF and d[i][k] != INF){
d[j][k] = d[j][i] + d[i][k];
}
}
}
}
return d;
}
Run Code Online (Sandbox Code Playgroud)
在图表上运行算法后:
from: to: weight:
0 1 1
1 …Run Code Online (Sandbox Code Playgroud) 我安装了Python 2.7和3.5.如果我使用命令行运行脚本python,它使用Python 2.7,但如果我启动iPython,它使用Python 3:
kurt@kurt-ThinkPad:~$ python -V
Python 2.7.12
kurt@kurt-ThinkPad:~$ ipython
Python 3.5.2 (default, Sep 10 2016, 08:21:44)
Type "copyright", "credits" or "license" for more information.
IPython 5.1.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]:
Run Code Online (Sandbox Code Playgroud)
有没有办法启动iPython以便它使用Python 2?(我正在使用Ubuntu LTS 16.04).
为了使用Docker SDK for Python,我正在尝试import docker使用Python脚本,但它产生ImportError了以下回溯:
Traceback (most recent call last):
File "/home/kurt/dev/clones8/ipercron-compose/furion/iclib/tests/test_utils/docker_utils.py", line 1, in <module>
import docker
File "/home/kurt/.local/lib/python2.7/site-packages/docker/__init__.py", line 6, in <module>
from .client import Client, AutoVersionClient, from_env # flake8: noqa
File "/home/kurt/.local/lib/python2.7/site-packages/docker/client.py", line 11, in <module>
from . import api
File "/home/kurt/.local/lib/python2.7/site-packages/docker/api/__init__.py", line 2, in <module>
from .build import BuildApiMixin
File "/home/kurt/.local/lib/python2.7/site-packages/docker/api/build.py", line 9, in <module>
from .. import utils
File "/home/kurt/.local/lib/python2.7/site-packages/docker/utils/__init__.py", line 2, in <module>
from .utils import (
File …Run Code Online (Sandbox Code Playgroud) 我正在尝试构建具有以下文件结构的React Native应用程序:
Kurts-MacBook-Pro-2:lucy-app kurtpeek$ tree -L 1
.
??? README.md
??? __tests__
??? android
??? app.json
??? assets
??? index.js
??? ios
??? node_modules
??? package.json
??? src
??? yarn.lock
Run Code Online (Sandbox Code Playgroud)
的package.json是
{
"name": "app",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "concurrently 'emulator @Nexus_5X_API_27_x86' 'yarn android-noavd'",
"android-noavd": "react-native run-android",
"android-px": "concurrently 'emulator @Pixel_2_API_27' 'yarn android-noavd'",
"android:release": "cross-env ENVFILE=.env.release yarn run android",
"android:staging": "cross-env ENVFILE=.env.staging yarn run android",
"build:android:dev": "cross-env ENVFILE=.env ./android/gradlew assembleRelease -p ./android/",
"build:android:release": "cross-env ENVFILE=.env.release ./android/gradlew …Run Code Online (Sandbox Code Playgroud) 我想确保我使用的是撰写文件格式的第3版.但是,在https://docs.docker.com/compose/compose-file/上我无法找到如何执行此操作.
我的Docker版本是17.04.0-ce, build 4845c56,我的Docker-Compose版本是docker-compose version 1.9.0, build 2585387.但是,我不确定从何时引入了撰写文件格式的第3版.我怎么能找到这个?
鉴于Series喜欢
import pandas as pd
s = pd.Series(['foo', 'bar', 42])
Run Code Online (Sandbox Code Playgroud)
我想获得一个"子系列" pd.Series(['foo', 'bar']),其中所有值都是字符串.我试过像这样的布尔索引:
s[isinstance(s, str)]
Run Code Online (Sandbox Code Playgroud)
但这给了一个
KeyError:错误
到目前为止,在我搜索合适的方法时,我遇到了select,但这会在标签上强加一个标准,而不是值.在这种情况下,如何根据值(类型)进行过滤?
python ×5
docker ×2
bluejeans ×1
django ×1
egg ×1
ios ×1
ipython ×1
java ×1
matplotlib ×1
objective-c ×1
pandas ×1
pip ×1
pipenv ×1
plot ×1
postgresql ×1
python-2.7 ×1
react-native ×1
reactjs ×1
spyder ×1