这些天升级时,我收到以下消息:
$ sudo apt-get upgrade -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages have been kept back:
libhwloc-plugins linux-headers-generic linux-signed-generic
linux-signed-image-generic python-pip
0 upgraded, 0 newly installed, 0 to remove and 5 not upgraded.
Run Code Online (Sandbox Code Playgroud)
我不明白为什么python-pip被阻止。是因为我已经更新pip了吗?
$ pip -V
pip 7.0.3 from /usr/local/lib/python2.7/dist-packages (python 2.7)
Run Code Online (Sandbox Code Playgroud)
它是现在可以安全地升级python-pip使用apt-get?
更新:
$ sudo apt-get install python-pip
Reading package lists... Done
Building dependency tree
Reading state information... Done …Run Code Online (Sandbox Code Playgroud) 我刚刚安装了nltk,当我的默认python是2.7版本时,现在当我打开python3(3.4版本)时,我无法导入nltk,有没有什么解决方案,让nltk对两个版本都可用?
假设我有 1000 个 csv 文件,这些文件在文件夹中具有随机名称test。我有一个 python 脚本script.py。我想编写一个 bash 脚本,它会传递文件夹中每个文件的名称script.py然后运行它,因此 bash 脚本应该运行script.py1000 次,每次使用不同的文件名,例如,首先运行:
with open('records.csv','r') as in_file
Run Code Online (Sandbox Code Playgroud)
下一次运行
with open('vertigo.csv','r') as in_file
Run Code Online (Sandbox Code Playgroud)
我知道我可以在 python 中做到这一点,而无需像这样编写 bash 脚本
import glob
for filename in glob.glob('*.csv'):
# script here
Run Code Online (Sandbox Code Playgroud)
但是我正在做一些测试,因此我想在 bash 中进行
我在 bash 中有这段代码,不知道如何翻译带有“ps -C .....”和“ps -eo ....”的行,对如何编写这些行有任何帮助吗?
if [ "$SwapUsedActivity" == "true" ]
then
echo "WARNING: Potential Swapping happening please check for increasing swap usage"
echo "INFO: checking kswapd number of process and cputime, check for TIME colume for how busy kswapd was"
ps -C kswapd0 -C kswapd1 -C kswapd2 -C kswapd3 -C kswapd4 -o pid,ppid,stime,etime,time,pcpu,args
else
echo "INFO: High swap space usage detected, not a potential issue but check activity"
fi
else
echo "INFO: Swap usage within the limits" …Run Code Online (Sandbox Code Playgroud) 我正在使用 Inkscape 0.91 (r13725),当我尝试使用 Perspective 插件或尝试以任何格式保存草图时,我总是收到此错误消息:
The fantastic lxml wrapper for libxml2 is required by inkex.py and therefore this extension.
Please download and install the latest version from http://cheeseshop.python.org/pypi/lxml/, or install it through your package manager by a command like: sudo apt-get install python-lxml
Technical details: No module named lxml
Run Code Online (Sandbox Code Playgroud)
而且我已经安装了 python-lxml 包,但什么也没发生。
谁能帮我?感谢您的回答!
我使用 pygame 创建了一个游戏,我希望将其导出到.exe文件中。我为此使用了 pyinstaller,因为它可用于 Ubuntu。当我运行时--onefile game,它工作得很好(在我的 ubuntu 计算机上)。但是,当我将它发送给拥有 Windows 的朋友时,它不是 Windows 可执行文件,而只是一个没有任何扩展名的“文件”。他不能运行它。重命名它Game.exe也没有奏效。
我没主意了……有人可以帮忙吗?
几个月前我在 Ubuntu 中制作了我的 Python 默认版本 Python 3,但我不知道我是怎么做到的。现在我正在尝试安装 pygame,但它抛出了许多错误。感觉是因为我的默认Python改了。我想恢复更改前的原始状态。
我是 Linux 和 Python 新手,所以如果您需要任何其他信息,请告诉我。
更新 ls -l /usr/bin | grep python
-rwxr-xr-x 1 root root 1824 Feb 10 16:51 activate-global-python-argcomplete3
lrwxrwxrwx 1 root root 26 Mei 18 17:10 dh_pypy -> ../share/dh-python/dh_pypy
-rwxr-xr-x 1 root root 1056 Dis 10 2015 dh_python2
lrwxrwxrwx 1 root root 29 Mei 18 17:10 dh_python3 -> ../share/dh-python/dh_python3
lrwxrwxrwx 1 root root 23 Jul 3 03:05 pdb2.7 -> ../lib/python2.7/pdb.py
lrwxrwxrwx 1 root root 23 Jul 7 17:17 pdb3.5 …Run Code Online (Sandbox Code Playgroud) 我有Ubuntu 16.04.1 LTS和 buildbot 0.8.12-3。
我试过像这样启动 buildbot:
cd /var/lib/buildbot/masters/
sudo buildbot create-master test
cd test/
sudo cp master.cfg.sample master.cfg
sudo buildbot start
Run Code Online (Sandbox Code Playgroud)
作为输出,我得到了:
exceptions.AttributeError: Requirements are not satisfied for buildbot.buildslave:BuildSlave: (sqlalchemy-migrate 0.10.0 (/usr/lib/python2.7/dist-packages), Requirement.parse('sqlalchemy-migrate==0.7.2'))
Run Code Online (Sandbox Code Playgroud)
并且只有 buildbot 使用 python-sqlalchemy 和 python-migration
$ aptitude why python-sqlalchemy
i buildbot Depends python-sqlalchemy (< 1.1)
Run Code Online (Sandbox Code Playgroud)
所以看起来甚至没有人在打包之前运行 buildbot。
解决此问题的最佳方法是什么?安装pip并使用它来安装正确版本的 sqlalchemy 或下载软件包源,修复它并重建,也许还有其他选择?
这是我的 CSV 文件的示例:
04/Feb/2016:06:38:44-0500,ab,3,10,57,200,10254
04/Feb/2016:06:39:07-0500,cd,1,42,168,304,0
04/Feb/2016:06:39:07-0500,ef,1,43,169,304,0
04/Feb/2016:06:39:07-0500,ab,1,43,170,304,0
04/Feb/2016:06:39:07-0500,cd,1,44,171,304,0
04/Feb/2016:06:39:07-0500,ef,1,45,172,304,0
Run Code Online (Sandbox Code Playgroud)
我想在第二列中获取字符串,如果文件不存在则创建类似该字符串的文件,并在文件中添加该特定行。所以像这样:
fetch string in 2nd column -> "ab" -> if file doesnt exist create file called "ab.csv" -> open file and add line "04/Feb/2016:06:38:44-0500,ab,3,10,57,200,10254"
fetch string in 2nd column -> "cd" -> if file doesnt exist create file called "cd.csv" -> open file and add line "04/Feb/2016:06:39:07-0500,cd,1,42,168,304,0"
fetch string in 2nd column -> "ef" -> if file doesnt exist create file called "ef.csv" -> open file and add line "04/Feb/2016:06:39:07-0500,ef,1,43,169,304,0"
fetch …Run Code Online (Sandbox Code Playgroud) 如何在 Ubuntu 14.04 中为 Python 2.7 安装 Jupyter?
我试过:
sudo add-apt-repository ppa:jolicloud-team/ppa
sudo apt-get update
Run Code Online (Sandbox Code Playgroud)
更新输出:
Ign file: InRelease
Get:1 file: Release.gpg [181 B]
Get:2 file: Release [196 B]
Ign file: Translation-en_US
Ign file: Translation-en
Hit http://storage.googleapis.com stable InRelease
Ign http://us.archive.ubuntu.com trusty/universe Translation-en_US
Fetched 5,905 kB in 6s (915 kB/s)
W: Failed to fetch http://ppa.launchpad.net/jolicloud-team/ppa/ubuntu/dists/trusty/main/binary-amd64/Packages 404 Not Found
W: Failed to fetch http://ppa.launchpad.net/jolicloud-team/ppa/ubuntu/dists/trusty/main/binary-i386/Packages 404 Not Found
E: Some index files failed to download. They have been ignored, or old ones …Run Code Online (Sandbox Code Playgroud) python ×10
apt ×3
bash ×3
command-line ×2
14.04 ×1
awk ×1
executable ×1
inkscape ×1
jupyter ×1
ppa ×1
python-2.7 ×1
python3 ×1
scripts ×1