我的py文件可以在python3.6.2上运行,但是却不能在终端上运行,不知道问题出在哪,请求大佬帮帮忙,谢谢。
#!/usr/bin/python
"""
Created on Fri Dec  7 20:27:44 2018

@author: 10748
"""


import os
import filetype
import sys
import tensorflow as tf

def train(file):

    a_list = list()
    # change this as you see fit
    image_path = file

# Read in the image_data
    image_data = tf.gfile.FastGFile(image_path, 'rb').read()

# Loads label file, strips off carriage return
    label_lines = [line.rstrip() for line
                   in tf.gfile.GFile("output_labels.txt")]

# Unpersists graph from file
    with tf.gfile.FastGFile("output_graph.pb", 'rb') as f:
        graph_def = tf.GraphDef()
        graph_def.ParseFromString(f.read())
        _ = tf.import_graph_def(graph_def, name='')

    with tf.Session() as sess:
    # Feed the image_data as input to the graph and get first prediction
        softmax_tensor = sess.graph.get_tensor_by_name('final_result:0')

        predictions = sess.run(softmax_tensor, \
                {'DecodeJpeg/contents:0': image_data})

    # Sort to show labels of first prediction in order of confidence
        top_k = predictions[0].argsort()[-len(predictions[0]):][::-1]

        for node_id in top_k:
            human_string = label_lines[node_id]
            score = predictions[0][node_id]
            a_list.append(human_string+'_score = '+str(score))
    return a_list



def file_type(file):
     try:
        b = filetype.guess(file)
        c = b.extension
        if c == 'jpg':
            return file
     except:
         return

file_list = list()

for root, dirs, files in os.walk(".", topdown=False):
    for name in files:
        file_list.append(os.path.join(name))

for i in range(len(file_list)):
    file_name = file_type(file_list[i])
    if file_name == None:
        print('')
    else:
        a =train(file_name)

for q in range (len(a)):
    print(a[q])

input('按下回车键退出')

终端上显示:
Traceback (most recent call last):
File "D:\Anaconda3\envs\tensorflow-gpu\flow\data\train\TS.py", line 35, in
for q in range (len(a)):
NameError: name 'a' is not defined

1个回答

for i in range(len(file_list)):
    file_name = file_type(file_list[i])
    if file_name == None:
        print('')
    else:
        a =train(file_name)

a在这定义, 出错问题就在这.
"在python3.6.2运行"是什么意思, "在终端运行"又是什么意思....麻烦把这些都叙述明白....
根据你这模糊的说法, 应该是工作目录的问题, 你os.walk直接遍历的是当前工作目录
终端切到所在目录应该就行了

qq_38436848
qq_38436848 不好意思,我确实没说清楚 "在python3.6.2运行"是指我用python写然后直接点击运行 ,"在终端运行"我是在开始菜单直接输cmd调出终端,确实如你所说的,直接切到所在目录就可以运行了 谢谢你!
大约一年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
ubuntu18.04 python3.6 pip安装mysqlclient报错
ubuntu18.04 python3.6 pip安装mysqlclient报错 求大佬解答 ``` Building wheels for collected packages: mysqlclient Running setup.py bdist_wheel for mysqlclient ... error Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-njxuuzpo/mysqlclient/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/tmpzs54ny_2pip-wheel- --python-tag cp36: running bdist_wheel running build running build_py creating build creating build/lib.linux-x86_64-3.6 creating build/lib.linux-x86_64-3.6/MySQLdb copying MySQLdb/__init__.py -> build/lib.linux-x86_64-3.6/MySQLdb copying MySQLdb/_exceptions.py -> build/lib.linux-x86_64-3.6/MySQLdb copying MySQLdb/compat.py -> build/lib.linux-x86_64-3.6/MySQLdb copying MySQLdb/connections.py -> build/lib.linux-x86_64-3.6/MySQLdb copying MySQLdb/converters.py -> build/lib.linux-x86_64-3.6/MySQLdb copying MySQLdb/cursors.py -> build/lib.linux-x86_64-3.6/MySQLdb copying MySQLdb/release.py -> build/lib.linux-x86_64-3.6/MySQLdb copying MySQLdb/times.py -> build/lib.linux-x86_64-3.6/MySQLdb creating build/lib.linux-x86_64-3.6/MySQLdb/constants copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants running build_ext building 'MySQLdb._mysql' extension creating build/temp.linux-x86_64-3.6 creating build/temp.linux-x86_64-3.6/MySQLdb x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Dversion_info=(1,4,5,'final',0) -D__version__=1.4.5 -I/usr/include/mysql -I/usr/include/python3.6m -c MySQLdb/_mysql.c -o build/temp.linux-x86_64-3.6/MySQLdb/_mysql.o x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-Bsymbolic-functions -Wl,-z,relro -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.6/MySQLdb/_mysql.o -lmysqlclient -lpthread -lz -lm -lrt -latomic -lssl -lcrypto -ldl -o build/lib.linux-x86_64-3.6/MySQLdb/_mysql.cpython-36m-x86_64-linux-gnu.so /usr/bin/ld: cannot find -lssl /usr/bin/ld: cannot find -lcrypto collect2: error: ld returned 1 exit status error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 ---------------------------------------- Failed building wheel for mysqlclient Running setup.py clean for mysqlclient Failed to build mysqlclient Installing collected packages: mysqlclient Running setup.py install for mysqlclient ... error Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-njxuuzpo/mysqlclient/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-ldoqhl56-record/install-record.txt --single-version-externally-managed --compile --user --prefix=: running install running build running build_py creating build creating build/lib.linux-x86_64-3.6 creating build/lib.linux-x86_64-3.6/MySQLdb copying MySQLdb/__init__.py -> build/lib.linux-x86_64-3.6/MySQLdb copying MySQLdb/_exceptions.py -> build/lib.linux-x86_64-3.6/MySQLdb copying MySQLdb/compat.py -> build/lib.linux-x86_64-3.6/MySQLdb copying MySQLdb/connections.py -> build/lib.linux-x86_64-3.6/MySQLdb copying MySQLdb/converters.py -> build/lib.linux-x86_64-3.6/MySQLdb copying MySQLdb/cursors.py -> build/lib.linux-x86_64-3.6/MySQLdb copying MySQLdb/release.py -> build/lib.linux-x86_64-3.6/MySQLdb copying MySQLdb/times.py -> build/lib.linux-x86_64-3.6/MySQLdb creating build/lib.linux-x86_64-3.6/MySQLdb/constants copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants running build_ext building 'MySQLdb._mysql' extension creating build/temp.linux-x86_64-3.6 creating build/temp.linux-x86_64-3.6/MySQLdb x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Dversion_info=(1,4,5,'final',0) -D__version__=1.4.5 -I/usr/include/mysql -I/usr/include/python3.6m -c MySQLdb/_mysql.c -o build/temp.linux-x86_64-3.6/MySQLdb/_mysql.o x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-Bsymbolic-functions -Wl,-z,relro -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.6/MySQLdb/_mysql.o -lmysqlclient -lpthread -lz -lm -lrt -latomic -lssl -lcrypto -ldl -o build/lib.linux-x86_64-3.6/MySQLdb/_mysql.cpython-36m-x86_64-linux-gnu.so /usr/bin/ld: cannot find -lssl /usr/bin/ld: cannot find -lcrypto collect2: error: ld returned 1 exit status error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 ---------------------------------------- Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-njxuuzpo/mysqlclient/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-ldoqhl56-record/install-record.txt --single-version-externally-managed --compile --user --prefix=" failed with error code 1 in /tmp/pip-build-njxuuzpo/mysqlclient/ ```
python文件修改后缀为.pyw文件无法运行
1. 问题描述: 我有一个正常能运行的python文件`test.py`(可以通过`python test.py`在命令行窗口运行),但是修改这个文件后缀为.pyw后,双击该文件就无法运行。 2. test.py源码: ```python from win10toast import ToastNotifier toast = ToastNotifier() toast.show_toast('test title','test content') ```` 3. 代码正常运行情况下的结果: 在windows会出现通知弹窗。通过命令`python test.py`可以运行,但是修改为`test.pyw`并双击运行就没反应 4. 代码环境: win10,python3.6 5. 已排除原因: 1. 不是因为没有关联pythonw.exe,因为通过其他的python文件,修改为.pyw文件双击之后能正常运行,排除了这个原因 2. 不是代码问题,因为通过命令`python test.py`能正常运行
python subprocess.call()执行其他目录下.py文件的疑问
python 新手,下载别人的代码自己跑,有一段执行其他目录下的python文件的代码,会报错。 ``` cmd = './b/b.py' subprocess.call(cmd, shell=True) ``` 报错为 **'.' 不是内部或外部命令,也不是可运行的程序 或批处理文件。** 请问这是怎么解决? 运行环境为win10,python3.6
django.db.utils.InternalError: (1050, "Table 'django_content_type' already exists") 迁移文件建立数据表的时候一直报错
django.db.utils.InternalError: (1050, "Table 'django_content_type' already exists") 在网上看到很多的方法,大概都是 先删除 所有的迁移文件, 再删除 数据库中对应的 Django_migrations 表里面的所有数据 之后再进行创建迁移文件然后再执行创建数据表的操作,但是报 没有应用啥啥啥的错误。。。 接着执行: python manage.py migrate booktest --fake 结果再执行 : python manage.py migrate 还是报 1050 的错误。。。。。。。。 下面附上详细报错信息,求网友大哥们解答~~!! (django_py3) huangdonglin@huangdonglin-virtual-machine:~/django_show/test2$ python manage.py migrate Operations to perform: Synchronize unmigrated apps: messages, staticfiles Apply all migrations: admin, booktest, sessions, auth, contenttypes Synchronizing apps without migrations: Creating tables... Running deferred SQL... Installing custom SQL... Running migrations: Rendering model states... DONE Applying contenttypes.0001_initial...Traceback (most recent call last): File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/django/db/backends/utils.py", line 62, in execute return self.cursor.execute(sql) File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 124, in execute return self.cursor.execute(query, args) File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/pymysql/cursors.py", line 170, in execute result = self._query(query) File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/pymysql/cursors.py", line 328, in _query conn.query(q) File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/pymysql/connections.py", line 517, in query self._affected_rows = self._read_query_result(unbuffered=unbuffered) File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/pymysql/connections.py", line 732, in _read_query_result result.read() File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/pymysql/connections.py", line 1075, in read first_packet = self.connection._read_packet() File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/pymysql/connections.py", line 684, in _read_packet packet.check_error() File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/pymysql/protocol.py", line 220, in check_error err.raise_mysql_exception(self._data) File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/pymysql/err.py", line 109, in raise_mysql_exception raise errorclass(errno, errval) pymysql.err.InternalError: (1050, "Table 'django_content_type' already exists") The above exception was the direct cause of the following exception: Traceback (most recent call last): File "manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line utility.execute() File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/django/core/management/__init__.py", line 330, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/django/core/management/base.py", line 390, in run_from_argv self.execute(*args, **cmd_options) File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/django/core/management/base.py", line 441, in execute output = self.handle(*args, **options) File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 221, in handle executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial) File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/django/db/migrations/executor.py", line 110, in migrate self.apply_migration(states[migration], migration, fake=fake, fake_initial=fake_initial) File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/django/db/migrations/executor.py", line 147, in apply_migration state = migration.apply(state, schema_editor) File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/django/db/migrations/migration.py", line 115, in apply operation.database_forwards(self.app_label, schema_editor, old_state, project_state) File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/django/db/migrations/operations/models.py", line 59, in database_forwards schema_editor.create_model(model) File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/django/db/backends/base/schema.py", line 286, in create_model self.execute(sql, params or None) File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/django/db/backends/base/schema.py", line 111, in execute cursor.execute(sql, params) File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/django/db/backends/utils.py", line 79, in execute return super(CursorDebugWrapper, self).execute(sql, params) File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/django/db/backends/utils.py", line 64, in execute return self.cursor.execute(sql, params) File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/django/db/utils.py", line 97, in __exit__ six.reraise(dj_exc_type, dj_exc_value, traceback) File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/django/utils/six.py", line 658, in reraise raise value.with_traceback(tb) File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/django/db/backends/utils.py", line 62, in execute return self.cursor.execute(sql) File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 124, in execute return self.cursor.execute(query, args) File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/pymysql/cursors.py", line 170, in execute result = self._query(query) File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/pymysql/cursors.py", line 328, in _query conn.query(q) File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/pymysql/connections.py", line 517, in query self._affected_rows = self._read_query_result(unbuffered=unbuffered) File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/pymysql/connections.py", line 732, in _read_query_result result.read() File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/pymysql/connections.py", line 1075, in read first_packet = self.connection._read_packet() File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/pymysql/connections.py", line 684, in _read_packet packet.check_error() File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/pymysql/protocol.py", line 220, in check_error err.raise_mysql_exception(self._data) File "/home/huangdonglin/.virtualenvs/django_py3/lib/python3.6/site-packages/pymysql/err.py", line 109, in raise_mysql_exception raise errorclass(errno, errval)
我给自己的Python程序写了一个setup.py文件,可以安装,但是无法import,执行可执行文件也报错怎么办?
我自己写了一个用于科学计算的Python程序,用于比较晶体结构相似性,对大批量的晶体结构自动分类,方法原理我在这篇文章里描述了[J. Phys. Condens. Matter 2017, 29, 165901]。现在我想做成一个Python egg,写了一个setup.py文件如下: ``` from setuptools import setup, find_packages setup( name='spap', version='0.3.0', packages=find_packages(), license='GPL', platforms="Independant", # install_requires=['numpy>=1.8.0', 'spglib>=1.10.0', 'ase>=3.13.0'], install_requires=['numpy', 'spglib', 'ase'], entry_points={ 'console_scripts': [ 'spap = src.spap:start_cli', ] } ) ``` 我用sudo python3 setup.py install能安装,安装包的目录如下所示: ``` ./ ├── build │   ├── bdist.linux-x86_64 │   └── lib │   └── src │   ├── ccf.py │   ├── __init__.py │   └── spap.py ├── dist │   └── spap-0.3.0-py3.6.egg ├── example │   └── run.py ├── setup.py ├── spap.egg-info │   ├── dependency_links.txt │   ├── entry_points.txt │   ├── PKG-INFO │   ├── requires.txt │   ├── SOURCES.txt │   └── top_level.txt └── src ├── ccf.py ├── __init__.py └── spap.py 8 directories, 15 files ``` 可以安装到系统上,pip3 list能显示出来,我执行spap -h命令就出错: ``` Traceback (most recent call last): File "/usr/local/bin/spap", line 11, in <module> load_entry_point('spap==0.3.0', 'console_scripts', 'spap')() File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 480, in load_entry_point return get_distribution(dist).load_entry_point(group, name) File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2693, in load_entry_point return ep.load() File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2324, in load return self.resolve() File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2330, in resolve module = __import__(self.module_name, fromlist=['__name__'], level=0) File "/usr/local/lib/python3.6/dist-packages/spap-0.3.0-py3.6.egg/src/spap.py", line 70, in <module> ModuleNotFoundError: No module named 'ccf' ``` 而且在python3里import spap输出如下: ``` >>> import spap Traceback (most recent call last): File "<stdin>", line 1, in <module> ModuleNotFoundError: No module named 'spap' ``` 请问这个怎么办?
linux 系统下python pyinstaller -F .py后生成单一可执行dist文件,在别的linux电脑运行发生报错
报错信息: Traceback (most recent call last): File "just.py", line 10, in <module> File "/usr/local/lib/python2.7/dist-packages/PyInstaller-3.4-py2.7.egg/PyInstaller/loader/pyimod03_importers.py", line 684, in load_module ImportError: /lib/x86_64-linux-gnu/ibc.so.6l: version `GLIBC_2.25' not found (required by /tmp/_MEIXyxj20/libexpat.so.1) [14385] Failed to execute script just 报错信息可知生成的可执行文件试图寻找pyimod03_importers.py文件,但所寻路径为原电脑路径,/libc.so.6也为原文件路径,故不能找到GLIBC_2.25 但pyinstaller -F .py所生成的单一执行文件不是不依赖环境和数据库吗 .................................................... 已尝试更新GLIBC_2.25,但仍从报错路径下查找
python 3.7引用docx操作word文档报错exception
python 3.7引用docx操作word文档报错“docx.opc.exceptions.PackageNotFoundError: Package not found at.....”,网上搜的方法都尝试过了,没有用。python__docx-0.8.6-py2.py3-none-any.whl这个包已经没有了,下载了python__docx-0.8.7-py2.py3-none-any.whl。但是仍然报错。求大神帮忙,给个终极解决办法。
python3.6 django1.11文件编码问题
我用django生成的初始文件执行python manage.py runserver 都提示 utf-8 can't decode.请问这是设置问题吗![图片](https://img-ask.csdn.net/upload/201710/14/1507914538_380682.png)
py4j.protocol.Py4JJavaError: //java.io.FileNotFoundException
Cent OS 运行机器训练程序,报错如下: ``` Traceback (most recent call last): File "trainKundur2areaGenBrakingAgent.py", line 42, in <module> ob_act_dim_ary = ipss_app.initStudyCase(case_files_array , dyn_config_file, rl_config_file) File "/root/anaconda3/envs/py3ml/lib/python3.6/site-packages/py4j/java_gateway.py", line 1286, in __call__ answer, self.gateway_client, self.target_id, self.name) File "/root/anaconda3/envs/py3ml/lib/python3.6/site-packages/py4j/protocol.py", line 328, in get_return_value format(target_id, ".", name), value) py4j.protocol.Py4JJavaError: An error occurred while calling t.initStudyCase. : java.io.FileNotFoundException: testData/Kundur-2area/json/kundur2area_dyn_config.json (没有那个文件或目录) at java.io.FileInputStream.open(Native Method) at java.io.FileInputStream.<init>(FileInputStream.java:131) at org.interpss.util.FileUtil.readFile(FileUtil.java:96) at org.interpss.pssl.plugin.cmd.json.BaseJSONBean.toBean(BaseJSONBean.java:58) at org.pnnl.gov.pss_gateway.IpssPyGateway.initStudyCase(IpssPyGateway.java:133) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244) at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:357) at py4j.Gateway.invoke(Gateway.java:282) at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132) at py4j.commands.CallCommand.execute(CallCommand.java:79) at py4j.GatewayConnection.run(GatewayConnection.java:214) at java.lang.Thread.run(Thread.java:744) ``` 文件经检查存在,且路径正确。求问如何解决,谢谢。
python3.6安装pypsa包时报错,无法安装。
在使用pip install pypsa,安装报错如下![图片说明](https://img-ask.csdn.net/upload/201910/15/1571110476_72432.png)![图片说明](https://img-ask.csdn.net/upload/201910/15/1571110486_931164.png) ERROR: Command errored out with exit status 1: command: 'd:\python3\python.exe' 'd:\python3\lib\site-packages\pip\_vendor\pep517\_in_process.py' get_requires_for_build_wheel 'C:\Users\xyrrrr\AppData\Local\Temp\tmpk8s4cp1x' cwd: C:\Users\xyrrrr\AppData\Local\Temp\pip-install-y9r5hyt9\cartopy Complete output (3 lines): setup.py:171: UserWarning: Unable to determine GEOS version. Ensure you have 3.3.3 or later installed, or installation may fail. '.'.join(str(v) for v in GEOS_MIN_VERSION), )) Proj 4.9.0 must be installed. ---------------------------------------- ERROR: Command errored out with exit status 1: 'd:\python3\python.exe' 'd:\python3\lib\site-packages\pip\_vendor\pep517\_in_process.py' get_requires_for_build_wheel 'C:\Users\xyrrrr\AppData\Local\Temp\tmpk8s4cp1x' Check the logs for full command output. 查了很多,真的不懂如何解决,小白求专业人士帮助!谢谢。 一天也没解决,我就是一个刚下载python的小白 饶了我吧
在py3.6版本的anaconda环境的下的jupyter notebook共存py2和py3内核问题?
各位,请教下:我在基于py3.6的anaconda的jupyter notebook里多安装一个py2的内核,装完后在jupyter notebook点击new按钮后,确实有python2和python3![图片说明](https://img-ask.csdn.net/upload/201907/22/1563769410_111477.png) 但是每次切换,点python2,就总是提示该内核已经died,重启也一样![图片说明](https://img-ask.csdn.net/upload/201907/22/1563769633_966159.png)![图片说明](https://img-ask.csdn.net/upload/201907/22/1563769647_360468.png) 我的步骤是以下这样的: 1、先给anaconda安一个py2环境:conda create newpy27 python=2.7; 2、激活newpy27环境:activate newpy27 3、conda install ipykernel 4、python -m ipkernel install --user ★这个问题我搜了两天,很多相关联的帖子,但没有一个帖子有说到py2内核died的问题。 ★另外一个问题是,只有谷歌浏览器可以打开jupyter notebook(用conda prompt进入的jupyter notebook),也可以切换py3内核,但换成其他浏览器就不行了(360浏览器、火狐),这又是为何? 以上2个问题,折磨了我这个菜鸟2天了,无法破,求各位大神看看,菜鸟我感激不尽!
请教python3.6下的pickle.dump函数用法
请大侠帮我解惑,谢谢! import pickle shoplistfile='shoplist.data' shoplist=['apple','banana','mango'] f=open(shoplistfile, 'wb') pickle.dump(shoplist,f)#把对象储存到打开的文件中 f.close() del shoplist f=open(shoplistfile) storedlist=pickle.load(f) print(storedlist) 结果如下报错: D:\python\python.exe D:/python/程序/pickle.py Traceback (most recent call last): File "D:/python/程序/pickle.py", line 1, in <module> import pickle File "D:\python\程序\pickle.py", line 7, in <module> pickle.dump(shoplist,f)#把对象储存到打开的文件中 AttributeError: module 'pickle' has no attribute 'dump'
用pyinstaller封装python3.6脚本,生成的exe无法加载所需的包怎么办?
我已经尝试了各种办法,在创建exe的时候用-p命令添加python\lib\side-package里面我所要用的包的文件夹路径,或者在后面加上--path=,但是生成的exe文件在运行的时候还是会显示这样: ``` [15664] PyInstaller Bootloader 3.x [15664] LOADER: executable is E:\python\exe\dist\Timer.exe [15664] LOADER: homepath is E:\python\exe\dist [15664] LOADER: _MEIPASS2 is NULL [15664] LOADER: archivename is E:\python\exe\dist\Timer.exe [15664] LOADER: Extracting binaries [15664] LOADER: Executing self as child [15664] LOADER: set _MEIPASS2 to C:\Users\pm494\AppData\Local\Temp\_MEI156642 [15664] LOADER: Setting up to run child [15664] LOADER: Creating child process [15664] LOADER: Waiting for child process to finish... [17992] PyInstaller Bootloader 3.x [17992] LOADER: executable is E:\python\exe\dist\Timer.exe [17992] LOADER: homepath is E:\python\exe\dist [17992] LOADER: _MEIPASS2 is C:\Users\pm494\AppData\Local\Temp\_MEI156642 [17992] LOADER: archivename is E:\python\exe\dist\Timer.exe [17992] LOADER: SetDllDirectory(C:\Users\pm494\AppData\Local\Temp\_MEI156642) [17992] LOADER: Already in the child - running user's code. [17992] LOADER: manifestpath: C:\Users\pm494\AppData\Local\Temp\_MEI156642\Timer.exe.manifest [17992] LOADER: Activation context created [17992] LOADER: Activation context activated [17992] LOADER: Python library: C:\Users\pm494\AppData\Local\Temp\_MEI156642\python36.dll [17992] LOADER: Loaded functions from Python library. [17992] LOADER: Manipulating environment (sys.path, sys.prefix) [17992] LOADER: Pre-init sys.path is C:\Users\pm494\AppData\Local\Temp\_MEI156642\base_library.zip;C:\Users\pm494\AppData\Local\Temp\_MEI156642 [17992] LOADER: sys.prefix is C:\Users\pm494\AppData\Local\Temp\_MEI156642 [17992] LOADER: Setting runtime options [17992] LOADER: Bootloader option: pyi-windows-manifest-filename Timer.exe.manifest [17992] LOADER: Initializing python [17992] LOADER: Overriding Python's sys.path [17992] LOADER: Post-init sys.path is C:\Users\pm494\AppData\Local\Temp\_MEI156642\base_library.zip;C:\Users\pm494\AppData\Local\Temp\_MEI156642 [17992] LOADER: Setting sys.argv [17992] LOADER: setting sys._MEIPASS [17992] LOADER: importing modules from CArchive [17992] LOADER: extracted struct [17992] LOADER: callfunction returned... [17992] LOADER: extracted pyimod01_os_path [17992] LOADER: callfunction returned... [17992] LOADER: extracted pyimod02_archive [17992] LOADER: callfunction returned... [17992] LOADER: extracted pyimod03_importers [17992] LOADER: callfunction returned... [17992] LOADER: Installing PYZ archive with Python modules. [17992] LOADER: PYZ archive: out00-PYZ.pyz [17992] LOADER: Running pyiboot01_bootstrap.py [17992] LOADER: Running pyi_rth_win32comgenpy.py [17992] LOADER: Running Timer.py Traceback (most recent call last): File "Timer.py", line 24, in <module> ModuleNotFoundError: No module named 'logilib' [17992] Failed to execute script Timer [17992] LOADER: OK. [17992] LOADER: Cleaning up Python interpreter. [15664] LOADER: Back to parent (RC: -1) [15664] LOADER: Doing cleanup [15664] LOADER: Freeing archive status for E:\python\exe\dist\Timer.exe ``` 我尝试在另一台装有python3.5和要用的包的电脑上使用pyinstaller,按照同样的方法生成exe,运行结果是一样的。我看了看代码中的24行是加载BeautifulSoup命令:from bs4 import BeautifulSoup 谷歌看了半天也找到合适的解决办法,求大神帮我看看到底是怎么回事? pyinstaller运行过程是这样的: ``` E:\python\exe>pyinstaller -F -d Timer.py --path=E:/python/exe/Lib;E:/python/exe/Lib/site-package;E:/python/exe/Lib/site-packages/xlwings;E:/python/exe/Lib/site-packages/bs4;E:/python/exe/Lib/site-packages/selenium 5 WARNING: Internal error: early pywin32 import was introduced 63 INFO: PyInstaller: 3.2.1 63 INFO: Python: 3.6.2 64 INFO: Platform: Windows-10-10.0.14393-SP0 66 INFO: wrote E:\python\exe\Timer.spec 68 INFO: UPX is not available. 71 INFO: Extending PYTHONPATH with paths ['E:\\python\\exe', 'E:\\python\\exe\\Lib', 'E:\\python\\exe\\Lib\\site-package', 'E:\\python\\exe\\Lib\\site-packages\\xlwings', 'E:\\python\\exe\\Lib\\site-packages\\bs4', 'E:\\python\\exe\\Lib\\site-packages\\selenium', 'E:\\python\\exe'] 75 INFO: checking Analysis 76 INFO: Building Analysis because out00-Analysis.toc is non existent 77 INFO: Initializing module dependency graph... 80 INFO: Initializing module graph hooks... 82 INFO: Analyzing base_library.zip ... 2889 INFO: running Analysis out00-Analysis.toc 2892 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable required by D:\workapp\Python\python.exe 3230 INFO: Caching module hooks... 3234 INFO: Analyzing E:\python\exe\Timer.py 4930 INFO: Processing pre-safe import module hook win32com 6402 INFO: Loading module hooks... 6402 INFO: Loading module hook "hook-encodings.py"... 6488 INFO: Loading module hook "hook-pydoc.py"... 6489 INFO: Loading module hook "hook-pythoncom.py"... 6706 INFO: Loading module hook "hook-pywintypes.py"... 6915 INFO: Loading module hook "hook-selenium.py"... 6920 INFO: Loading module hook "hook-win32com.py"... 6920 INFO: Loading module hook "hook-xml.dom.domreg.py"... 6921 INFO: Loading module hook "hook-xml.py"... 6940 INFO: Looking for ctypes DLLs 7045 WARNING: library coredll required via ctypes not found 7054 INFO: Analyzing run-time hooks ... 7058 INFO: Including run-time hook 'pyi_rth_win32comgenpy.py' 7067 INFO: Looking for dynamic libraries 7380 INFO: Looking for eggs 7381 INFO: Using Python library D:\workapp\Python\python36.dll 7382 INFO: Found binding redirects: [] 7389 INFO: Warnings written to E:\python\exe\build\Timer\warnTimer.txt 7401 INFO: checking PYZ 7401 INFO: Building PYZ because out00-PYZ.toc is non existent 7403 INFO: Building PYZ (ZlibArchive) E:\python\exe\build\Timer\out00-PYZ.pyz 8492 INFO: Building PYZ (ZlibArchive) E:\python\exe\build\Timer\out00-PYZ.pyz completed successfully. 8503 INFO: checking PKG 8503 INFO: Building PKG because out00-PKG.toc is non existent 8504 INFO: Building PKG (CArchive) out00-PKG.pkg 11271 INFO: Building PKG (CArchive) out00-PKG.pkg completed successfully. 11275 INFO: Bootloader D:\workapp\Python\lib\site-packages\PyInstaller\bootloader\Windows-64bit\run_d.exe 11275 INFO: checking EXE 11276 INFO: Building EXE because out00-EXE.toc is non existent 11278 INFO: Building EXE from out00-EXE.toc 11279 INFO: Appending archive to EXE E:\python\exe\dist\Timer.exe 11288 INFO: Building EXE from out00-EXE.toc completed successfully. ``` ------------------------------------------------------------------------ 刚刚试了一下另一个包,发现问题可能就是出在脚本中的bs4上面,在加载另一个包的时候并没有问题,程序可以运行。所以为什么是bs4这个包?到底该怎么找到问题呢?
theano 报错 module 'configparser' has no attribute 'ConfigParser' 用的是Anaconda3 python3.6
>theano 报错 module 'configparser' has no attribute 'ConfigParser' 用的是Win10 Anaconda3 python3.6 ``` from sklearn.datasets import load_boston import theano.tensor as T import numpy as np import matplotlib.pyplot as plt import theano class Layer(object): def __init__(self,inputs,in_size,out_size,activation_function=None): self.W = theano.shared(np.random.normal(0,1,(in_size,out_size))) self.b = theano.shared(np.zeros((out_size,)) + 0.1) self.Wx_plus_b = T.dot(inputs, self.W) + self.b self.activation_function = activation_function if activation_function is None: self.outputs = self.Wx_plus_b else: self.outputs = self.activation_function(self.Wx_plus_b) def minmax_normalization(data): xs_max = np.max(data, axis=0) xs_min = np.min(data, axis=0) xs = (1-0)*(data - xs_min)/(xs_max - xs_min) + 0 return xs np.random.seed(100) x_dataset = load_boston() x_data = x_dataset.data # minmax normalization, rescale the inputs x_data = minmax_normalization(x_data) y_data = x_dataset.target[:,np.newaxis] #cross validation, train test data split x_train, y_train = x_data[:400], y_data[:400] x_test, y_test = x_data[400:], y_data[400:] x = T.dmatrix('x') y = T.dmatrix('y') l1 = Layer(x, 13, 50, T.tanh) l2 = Layer(l1.outputs, 50, 1, None) #compute cost cost = T.mean(T.square(l2.outputs - y)) #cost = T.mean(T.square(l2.outputs - y)) + 0.1*((l1.W**2).sum() + (l2.W**2).sum()) #l2 regulization #cost = T.mean(T.square(l2.outputs - y)) + 0.1*(abs(l1.W).sum() + abs(l2.W).sum()) #l1 regulization gW1, gb1, gW2, gb2 = T.grad(cost, [l1.W,l1.b,l2.W,l2.b]) #gradient descend learning_rate = 0.01 train = theano.function(inputs=[x,y], updates=[(l1.W,l1.W-learning_rate*gW1), (l1.b,l1.b-learning_rate*gb1), (l2.W,l2.W-learning_rate*gW2), (l2.b,l2.b-learning_rate*gb2)]) compute_cost = theano.function(inputs=[x,y], outputs=cost) #record cost train_err_list = [] test_err_list = [] learning_time = [] for i in range(1000): if 1%10 == 0: #record cost train_err_list.append(compute_cost(x_train,y_train)) test_err_list.append(compute_cost(x_test,y_test)) learning_time.append(i) #plot cost history plt.plot(learning_time, train_err_list, 'r-') plt.plot(learning_time, test_err_list,'b--') plt.show() #作者 morvan莫凡 https://morvanzhou.github.io ``` 报错了: Traceback (most recent call last): File "C:/Users/Elena/PycharmProjects/theano/regularization.py", line 1, in <module> from sklearn.datasets import load_boston File "C:\Users\Elena\Anaconda3\lib\site-packages\sklearn\datasets\__init__.py", line 22, in <module> from .twenty_newsgroups import fetch_20newsgroups File "C:\Users\Elena\Anaconda3\lib\site-packages\sklearn\datasets\twenty_newsgroups.py", line 44, in <module> from ..feature_extraction.text import CountVectorizer File "C:\Users\Elena\Anaconda3\lib\site-packages\sklearn\feature_extraction\__init__.py", line 10, in <module> from . import text File "C:\Users\Elena\Anaconda3\lib\site-packages\sklearn\feature_extraction\text.py", line 28, in <module> from ..preprocessing import normalize File "C:\Users\Elena\Anaconda3\lib\site-packages\sklearn\preprocessing\__init__.py", line 6, in <module> from ._function_transformer import FunctionTransformer File "C:\Users\Elena\Anaconda3\lib\site-packages\sklearn\preprocessing\_function_transformer.py", line 5, in <module> from ..utils.testing import assert_allclose_dense_sparse File "C:\Users\Elena\Anaconda3\lib\site-packages\sklearn\utils\testing.py", line 61, in <module> from nose.tools import raises as _nose_raises File "C:\Users\Elena\Anaconda3\lib\site-packages\nose\__init__.py", line 1, in <module> from nose.core import collector, main, run, run_exit, runmodule File "C:\Users\Elena\Anaconda3\lib\site-packages\nose\core.py", line 11, in <module> from nose.config import Config, all_config_files File "C:\Users\Elena\Anaconda3\lib\site-packages\nose\config.py", line 6, in <module> import configparser File "C:\Users\Elena\Anaconda3\Lib\site-packages\theano\configparser.py", line 15, in <module> import theano File "C:\Users\Elena\Anaconda3\lib\site-packages\theano\__init__.py", line 88, in <module> from theano.configdefaults import config File "C:\Users\Elena\Anaconda3\lib\site-packages\theano\configdefaults.py", line 17, in <module> from theano.configparser import (AddConfigVar, BoolParam, ConfigParam, EnumStr, File "C:\Users\Elena\Anaconda3\lib\site-packages\theano\configparser.py", line 77, in <module> theano_cfg = (configparser.ConfigParser if PY3 **AttributeError: module 'configparser' has no attribute 'ConfigParser**' 把theano里的configparser.py文件里的ConfigParser改成了configparser还是不行 换了模块import configparsor也不行。。。![图片说明](https://img-ask.csdn.net/upload/201909/30/1569832318_223436.png)
python2有easy_install 但是却无法使用是怎么回事?
按照该连接操作:https://blog.csdn.net/qq_40678222/article/details/82734870 ``` hellopython@ubuntu:~$ easy_install --version setuptools 41.6.0 from /home/hellopython/.local/lib/python2.7/site-packages (Python 2.7) hellopython@ubuntu:~$ sudo easy_install virtualenvwrapper sudo: easy_install: command not found hellopython@ubuntu:~$ cd /home/hellopython/.local/lib/python2.7/site-packages hellopython@ubuntu:~/.local/lib/python2.7/site-packages$ ls decorator-4.4.1.dist-info retry decorator.py retry-0.9.2.dist-info decorator.pyc scrapy easy_install.py Scrapy-1.8.0.dist-info easy_install.pyc selenium ``` 请问这是为什么?python2里有easy_install.py ,但是却无法使用,是因为默认用python3解释器吗?怎么临时指定python2来执行呢?(不要长期)
在Selenium IED里面导出的.py文件在pycharm运行浏览器调取不了
``` # -*- coding: utf-8 -*- # Generated by Selenium IDE import pytest import time import json from selenium import webdriver #导入驱动, from selenium.webdriver.common.by import By from selenium.webdriver.common.action_chains import ActionChains from selenium.webdriver.support import expected_conditions from selenium.webdriver.support.wait import WebDriverWait from selenium.webdriver.common.keys import Keys time.sleep(5) class TestDenglu(): def setup_method(self, method): self.driver = webdriver.Chrome() self.vars = {} def teardown_method(self, method): self.driver.quit() time.sleep(5) def test_denglu(self): # Test name: denglu # Step # | name | target | value | comment # 1 | open | / | | self.driver.get("http://192.168.1.118:8083/") # 2 | setWindowSize | 945x1140 | | self.driver.set_window_size(945, 1140) time.sleep(5) # 3 | click | css=.login | | self.driver.find_element(By.CSS_SELECTOR, ".login").click() # 4 | click | css=.login-input:nth-child(3) > input | | self.driver.find_element(By.CSS_SELECTOR, ".login-input:nth-child(3) > input").click() # 5 | click | css=.login | | self.driver.find_element(By.CSS_SELECTOR, ".login").click() # 6 | click | css=.login-input:nth-child(3) > input | | self.driver.find_element(By.CSS_SELECTOR, ".login-input:nth-child(3) > input").click() # 7 | click | css=.login-button | | self.driver.find_element(By.CSS_SELECTOR, ".login-button").click() ```![图片说明](https://img-ask.csdn.net/upload/201909/27/1569567359_21132.png) 在Selenium IED里面导出的.py文件在pycharm运行浏览器调取不了
Python3.6+Selenium打不开Ie浏览器
【环境信息】 Python3.6+Selenium3.0.2+IE10+win7 【问题描述】 1、用如下代码打不开IE浏览器,但是能打开火狐浏览器 import unittest import os from selenium import webdriver class TestAutoMethods(unittest.TestCase): #打开Firefox浏览器 def test_openbrower(self): browser = webdriver.Firefox() browser.get("http://www.baidu.com") def test_FirstVase(self): #ie_driver = os.path.abspath(r"C:\Program Files(x86)\Internet Explorer\IEDriverServer.exe") #os.environ["webdriver.ie.driver"] = ie_driver browser = webdriver.Ie() browser.get("http://www.youdao.com") if __name__ == '__main__': unittest.main() 2、报错信息 复制代码 Error Traceback (most recent call last): File "D:\Users\chenle\PycharmProjects\untitled\test\FirstExam.py", line 14, in test_FirstVase browser = webdriver.Ie() File "C:\Program Files\Python36\lib\site-packages\selenium\webdriver\ie\webdriver.py", line 57, in __init__ desired_capabilities=capabilities) File "C:\Program Files\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 92, in __init__ self.start_session(desired_capabilities, browser_profile) File "C:\Program Files\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 179, in start_session response = self.execute(Command.NEW_SESSION, capabilities) File "C:\Program Files\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 234, in execute response = self.command_executor.execute(driver_command, params) File "C:\Program Files\Python36\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 408, in execute return self._request(command_info[0], url, body=data) File "C:\Program Files\Python36\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 478, in _request resp = opener.open(request, timeout=self._timeout) File "C:\Program Files\Python36\lib\urllib\request.py", line 526, in open response = self._open(req, data) File "C:\Program Files\Python36\lib\urllib\request.py", line 544, in _open '_open', req) File "C:\Program Files\Python36\lib\urllib\request.py", line 504, in _call_chain result = func(*args) File "C:\Program Files\Python36\lib\urllib\request.py", line 1346, in http_open return self.do_open(http.client.HTTPConnection, req) File "C:\Program Files\Python36\lib\urllib\request.py", line 1321, in do_open r = h.getresponse() File "C:\Program Files\Python36\lib\http\client.py", line 1331, in getresponse response.begin() File "C:\Program Files\Python36\lib\http\client.py", line 297, in begin version, status, reason = self._read_status() File "C:\Program Files\Python36\lib\http\client.py", line 266, in _read_status raise RemoteDisconnected("Remote end closed connection without" http.client.RemoteDisconnected: Remote end closed connection without response
python2.6.9的代码改成3.5.2运行, import Manager报错
由于工作原因,现在改用py3.5.2可是其中的一个文件开头的导包from multiprocessing import Manager就报错了怎么解决,顺便再问一下另一个文件里的copy()方法也报错,怎么解决,谢谢
python3.6+django2 创建后台管理账号报错 no attribute 'encoding
# AttributeError: '_io.BufferedWriter' object has no attribute 'encoding' ![图片说明](https://img-ask.csdn.net/upload/201811/14/1542186550_856400.jpg) ``` python manage.py makemigrations python manage.py migrate python manage.py createsuperuser ``` ![图片说明](https://img-ask.csdn.net/upload/201811/14/1542186681_307483.jpg) ## 我的后台页面是可以打开的: ![图片说明](https://img-ask.csdn.net/upload/201811/15/1542246566_171055.jpg) ## 后台代码配置如下: ![图片说明](https://img-ask.csdn.net/upload/201811/15/1542246590_797073.jpg) ## 用户创建失败,于是我自己在数据库手动添加了一个用户 ![图片说明](https://img-ask.csdn.net/upload/201811/15/1542246627_362301.jpg) ## 还是不能登录,但是请求200,报错如下 ![图片说明](https://img-ask.csdn.net/upload/201811/15/1542246654_472551.jpg) ## 创建超级管理员还是上面的错误:AttributeError: '_io.BufferedWriter' object has no attribute 'encoding' 请求大神帮忙,感谢!!!
相见恨晚的超实用网站
相见恨晚的超实用网站 持续更新中。。。
爬虫福利二 之 妹子图网MM批量下载
爬虫福利一:27报网MM批量下载 点击 看了本文,相信大家对爬虫一定会产生强烈的兴趣,激励自己去学习爬虫,在这里提前祝:大家学有所成! 目标网站:妹子图网 环境:Python3.x 相关第三方模块:requests、beautifulsoup4 Re:各位在测试时只需要将代码里的变量path 指定为你当前系统要保存的路径,使用 python xxx.py 或IDE运行即可。 ...
字节跳动视频编解码面经
三四月份投了字节跳动的实习(图形图像岗位),然后hr打电话过来问了一下会不会opengl,c++,shador,当时只会一点c++,其他两个都不会,也就直接被拒了。 七月初内推了字节跳动的提前批,因为内推没有具体的岗位,hr又打电话问要不要考虑一下图形图像岗,我说实习投过这个岗位不合适,不会opengl和shador,然后hr就说秋招更看重基础。我当时想着能进去就不错了,管他哪个岗呢,就同意了面试...
开源一个功能完整的SpringBoot项目框架
福利来了,给大家带来一个福利。 最近想了解一下有关Spring Boot的开源项目,看了很多开源的框架,大多是一些demo或者是一个未成形的项目,基本功能都不完整,尤其是用户权限和菜单方面几乎没有完整的。 想到我之前做的框架,里面通用模块有:用户模块,权限模块,菜单模块,功能模块也齐全了,每一个功能都是完整的。 打算把这个框架分享出来,供大家使用和学习。 为什么用框架? 框架可以学习整体...
源码阅读(19):Java中主要的Map结构——HashMap容器(下1)
HashMap容器从字面的理解就是,基于Hash算法构造的Map容器。从数据结构的知识体系来说,HashMap容器是散列表在Java中的具体表达(并非线性表结构)。具体来说就是,利用K-V键值对中键对象的某个属性(默认使用该对象的“内存起始位置”这一属性)作为计算依据进行哈希计算(调用hashCode方法),然后再以计算后的返回值为依据,将当前K-V键值对在符合HashMap容器构造原则的基础上,放置到HashMap容器的某个位置上,且这个位置和之前添加的K-V键值对的存储位置完全独立,不一定构成连续的存储
c++制作的植物大战僵尸,开源,一代二代结合游戏
此游戏全部由本人自己制作完成。游戏大部分的素材来源于原版游戏素材,少部分搜集于网络,以及自己制作。 此游戏为同人游戏而且仅供学习交流使用,任何人未经授权,不得对本游戏进行更改、盗用等,否则后果自负。目前有六种僵尸和六种植物,植物和僵尸的动画都是本人做的。qq:2117610943 开源代码下载 提取码:3vzm 点击下载--&gt; 11月28日 新增四种植物 统一植物画风,全部修...
Java学习的正确打开方式
在博主认为,对于入门级学习java的最佳学习方法莫过于视频+博客+书籍+总结,前三者博主将淋漓尽致地挥毫于这篇博客文章中,至于总结在于个人,实际上越到后面你会发现学习的最好方式就是阅读参考官方文档其次就是国内的书籍,博客次之,这又是一个层次了,这里暂时不提后面再谈。博主将为各位入门java保驾护航,各位只管冲鸭!!!上天是公平的,只要不辜负时间,时间自然不会辜负你。 何谓学习?博主所理解的学习,它是一个过程,是一个不断累积、不断沉淀、不断总结、善于传达自己的个人见解以及乐于分享的过程。
程序员必须掌握的核心算法有哪些?
由于我之前一直强调数据结构以及算法学习的重要性,所以就有一些读者经常问我,数据结构与算法应该要学习到哪个程度呢?,说实话,这个问题我不知道要怎么回答你,主要取决于你想学习到哪些程度,不过针对这个问题,我稍微总结一下我学过的算法知识点,以及我觉得值得学习的算法。这些算法与数据结构的学习大多数是零散的,并没有一本把他们全部覆盖的书籍。下面是我觉得值得学习的一些算法以及数据结构,当然,我也会整理一些看过...
Python——画一棵漂亮的樱花树(不同种樱花+玫瑰+圣诞树喔)
最近翻到一篇知乎,上面有不少用Python(大多是turtle库)绘制的树图,感觉很漂亮,我整理了一下,挑了一些我觉得不错的代码分享给大家(这些我都测试过,确实可以生成) one 樱花树 动态生成樱花 效果图(这个是动态的): 实现代码 import turtle as T import random import time # 画樱花的躯干(60,t) def Tree(branch, ...
linux系列之常用运维命令整理笔录
本博客记录工作中需要的linux运维命令,大学时候开始接触linux,会一些基本操作,可是都没有整理起来,加上是做开发,不做运维,有些命令忘记了,所以现在整理成博客,当然vi,文件操作等就不介绍了,慢慢积累一些其它拓展的命令,博客不定时更新 free -m 其中:m表示兆,也可以用g,注意都要小写 Men:表示物理内存统计 total:表示物理内存总数(total=used+free) use...
Python 基础(一):入门必备知识
Python 入门必备知识,你都掌握了吗?
深度学习图像算法在内容安全领域的应用
互联网给人们生活带来便利的同时也隐含了大量不良信息,防范互联网平台有害内容传播引起了多方面的高度关注。本次演讲从技术层面分享网易易盾在内容安全领域的算法实践经验,包括深度...
程序员接私活怎样防止做完了不给钱?
首先跟大家说明一点,我们做 IT 类的外包开发,是非标品开发,所以很有可能在开发过程中会有这样那样的需求修改,而这种需求修改很容易造成扯皮,进而影响到费用支付,甚至出现做完了项目收不到钱的情况。 那么,怎么保证自己的薪酬安全呢? 我们在开工前,一定要做好一些证据方面的准备(也就是“讨薪”的理论依据),这其中最重要的就是需求文档和验收标准。一定要让需求方提供这两个文档资料作为开发的基础。之后开发...
网页实现一个简单的音乐播放器(大佬别看。(⊙﹏⊙))
今天闲着无事,就想写点东西。然后听了下歌,就打算写个播放器。 于是乎用h5 audio的加上js简单的播放器完工了。 演示地点演示 html代码如下` music 这个年纪 七月的风 音乐 ` 然后就是css`*{ margin: 0; padding: 0; text-decoration: none; list-...
Python十大装B语法
Python 是一种代表简单思想的语言,其语法相对简单,很容易上手。不过,如果就此小视 Python 语法的精妙和深邃,那就大错特错了。本文精心筛选了最能展现 Python 语法之精妙的十个知识点,并附上详细的实例代码。如能在实战中融会贯通、灵活使用,必将使代码更为精炼、高效,同时也会极大提升代码B格,使之看上去更老练,读起来更优雅。
数据库优化 - SQL优化
以实际SQL入手,带你一步一步走上SQL优化之路!
2019年11月中国大陆编程语言排行榜
2019年11月2日,我统计了某招聘网站,获得有效程序员招聘数据9万条。针对招聘信息,提取编程语言关键字,并统计如下: 编程语言比例 rank pl_ percentage 1 java 33.62% 2 cpp 16.42% 3 c_sharp 12.82% 4 javascript 12.31% 5 python 7.93% 6 go 7.25% 7 p...
通俗易懂地给女朋友讲:线程池的内部原理
餐盘在灯光的照耀下格外晶莹洁白,女朋友拿起红酒杯轻轻地抿了一小口,对我说:“经常听你说线程池,到底线程池到底是个什么原理?”
经典算法(5)杨辉三角
写在前面: 我是 扬帆向海,这个昵称来源于我的名字以及女朋友的名字。我热爱技术、热爱开源、热爱编程。技术是开源的、知识是共享的。 这博客是对自己学习的一点点总结及记录,如果您对 Java、算法 感兴趣,可以关注我的动态,我们一起学习。 用知识改变命运,让我们的家人过上更好的生活。 目录一、杨辉三角的介绍二、杨辉三角的算法思想三、代码实现1.第一种写法2.第二种写法 一、杨辉三角的介绍 百度
腾讯算法面试题:64匹马8个跑道需要多少轮才能选出最快的四匹?
昨天,有网友私信我,说去阿里面试,彻底的被打击到了。问了为什么网上大量使用ThreadLocal的源码都会加上private static?他被难住了,因为他从来都没有考虑过这个问题。无独有偶,今天笔者又发现有网友吐槽了一道腾讯的面试题,我们一起来看看。 腾讯算法面试题:64匹马8个跑道需要多少轮才能选出最快的四匹? 在互联网职场论坛,一名程序员发帖求助到。二面腾讯,其中一个算法题:64匹...
面试官:你连RESTful都不知道我怎么敢要你?
干货,2019 RESTful最贱实践
为啥国人偏爱Mybatis,而老外喜欢Hibernate/JPA呢?
关于SQL和ORM的争论,永远都不会终止,我也一直在思考这个问题。昨天又跟群里的小伙伴进行了一番讨论,感触还是有一些,于是就有了今天这篇文。 声明:本文不会下关于Mybatis和JPA两个持久层框架哪个更好这样的结论。只是摆事实,讲道理,所以,请各位看官勿喷。 一、事件起因 关于Mybatis和JPA孰优孰劣的问题,争论已经很多年了。一直也没有结论,毕竟每个人的喜好和习惯是大不相同的。我也看...
项目中的if else太多了,该怎么重构?
介绍 最近跟着公司的大佬开发了一款IM系统,类似QQ和微信哈,就是聊天软件。我们有一部分业务逻辑是这样的 if (msgType = "文本") { // dosomething } else if(msgType = "图片") { // doshomething } else if(msgType = "视频") { // doshomething } else { // doshom...
致 Python 初学者
欢迎来到“Python进阶”专栏!来到这里的每一位同学,应该大致上学习了很多 Python 的基础知识,正在努力成长的过程中。在此期间,一定遇到了很多的困惑,对未来的学习方向感到迷茫。我非常理解你们所面临的处境。我从2007年开始接触 python 这门编程语言,从2009年开始单一使用 python 应对所有的开发工作,直至今天。回顾自己的学习过程,也曾经遇到过无数的困难,也曾经迷茫过、困惑过。开办这个专栏,正是为了帮助像我当年一样困惑的 Python 初学者走出困境、快速成长。希望我的经验能真正帮到你
Python 编程实用技巧
Python是一门很灵活的语言,也有很多实用的方法,有时候实现一个功能可以用多种方法实现,我这里总结了一些常用的方法,并会持续更新。
“狗屁不通文章生成器”登顶GitHub热榜,分分钟写出万字形式主义大作
一、垃圾文字生成器介绍 最近在浏览GitHub的时候,发现了这样一个骨骼清奇的雷人项目,而且热度还特别高。 项目中文名:狗屁不通文章生成器 项目英文名:BullshitGenerator 根据作者的介绍,他是偶尔需要一些中文文字用于GUI开发时测试文本渲染,因此开发了这个废话生成器。但由于生成的废话实在是太过富于哲理,所以最近已经被小伙伴们给玩坏了。 他的文风可能是这样的: 你发现,
程序员:我终于知道post和get的区别
IT界知名的程序员曾说:对于那些月薪三万以下,自称IT工程师的码农们,其实我们从来没有把他们归为我们IT工程师的队伍。他们虽然总是以IT工程师自居,但只是他们一厢情愿罢了。 此话一出,不知激起了多少(码农)程序员的愤怒,却又无可奈何,于是码农问程序员。 码农:你知道get和post请求到底有什么区别? 程序员:你看这篇就知道了。 码农:你月薪三万了? 程序员:嗯。 码农:你是怎么做到的? 程序员:
"狗屁不通文章生成器"登顶GitHub热榜,分分钟写出万字形式主义大作
前言 GitHub 被誉为全球最大的同性交友网站,……,陪伴我们已经走过 10+ 年时间,它托管了大量的软件代码,同时也承载了程序员无尽的欢乐。 上周给大家分享了一篇10个让你笑的合不拢嘴的Github项目,而且还拿了7万+个Star哦,有兴趣的朋友,可以看看, 印象最深刻的是 “ 呼吸不止,码字不停 ”: 老实交代,你是不是经常准备写个技术博客,打开word后瞬间灵感便秘,码不出字? 有什么
推荐几款比较实用的工具,网站
1.盘百度PanDownload 这个云盘工具是免费的,可以进行资源搜索,提速(偶尔会抽风????) 不要去某站买付费的???? PanDownload下载地址 2.BeJSON 这是一款拥有各种在线工具的网站,推荐它的主要原因是网站简洁,功能齐全,广告相比其他广告好太多了 bejson网站 3.二维码美化 这个网站的二维码美化很好看,网站界面也很...
《程序人生》系列-这个程序员只用了20行代码就拿了冠军
你知道的越多,你不知道的越多 点赞再看,养成习惯GitHub上已经开源https://github.com/JavaFamily,有一线大厂面试点脑图,欢迎Star和完善 前言 这一期不算《吊打面试官》系列的,所有没前言我直接开始。 絮叨 本来应该是没有这期的,看过我上期的小伙伴应该是知道的嘛,双十一比较忙嘛,要值班又要去帮忙拍摄年会的视频素材,还得搞个程序员一天的Vlog,还要写BU
相关热词 c#处理浮点数 c# 生成字母数字随机数 c# 动态曲线 控件 c# oracle 开发 c#选择字体大小的控件 c# usb 批量传输 c#10进制转8进制 c#转base64 c# 科学计算 c#下拉列表获取串口
立即提问

相似问题

1
python文件修改后缀为.pyw文件无法运行
1
cannot import name etree ------tf.app.run()命令行中运行脚本时报错
7
关于Python3.7中安装pip install Scrapy出现的问题
0
python3.7 下载email包,一直报错
1
linux 系统下python pyinstaller -F .py后生成单一可执行dist文件,在别的linux电脑运行发生报错
0
在py3.6版本的anaconda环境的下的jupyter notebook共存py2和py3内核问题?
1
Linux下 python import pdb出现无cmd属性
1
在Selenium IED里面导出的.py文件在pycharm运行浏览器调取不了
1
我给自己的Python程序写了一个setup.py文件,可以安装,但是无法import,执行可执行文件也报错怎么办?
1
theano 报错 module 'configparser' has no attribute 'ConfigParser' 用的是Anaconda3 python3.6
1
py4j.protocol.Py4JJavaError: //java.io.FileNotFoundException
1
如图 运行conda create -n py27 python=2.7 报错 该如何解决呢
1
python3.6安装pypsa包时报错,无法安装。
0
关于python使用DBUtils建立连接池连接数据库报错pymysql.err.OperationalError: (2014, 'Command Out of Sync')?
0
从python入门到实践19.2.2运行后登录界面没有出现注册页面,出现下面的错误
1
django.db.utils.InternalError: (1050, "Table 'django_content_type' already exists") 迁移文件建立数据表的时候一直报错
3
python2有easy_install 但是却无法使用是怎么回事?
1
Tensorflow测试训练styleGAN时报错 No OpKernel was registered to support Op 'NcclAllReduce' with these attrs.
1
部署flask项目到heroku上时,出现psycopg2.errors.UndefinedTable: relation "question" does not exist问题,该怎么解决?
1
ubuntu18.04 python3.6 pip安装mysqlclient报错