flask

配置Flask-CLI以便与Flask应用程序一起使用 在main.py中添加自定义命令。# main.py""""""")# 注册应用app.run() 阅读详情


Dismiss
Announcing Stack Overflow Documentation

We started with Q&A. Technical documentation is next, and we need your help.

Whether you're a beginner or an experienced developer, you can contribute.

Sign up and start helping →  Learn more about Documentation →

Having trouble with virtualenv on Windows 7.

I run:

virtualenv _testenv

It returns:

Traceback (most recent call last):
  File "C:\Python27\Scripts\virtualenv-script.py", line 9, in <module>
    load_entry_point('virtualenv==1.5.2', 'console_scripts', 'virtualenv')()
  File "C:\Python27\lib\site-packages\virtualenv.py", line 558, in main
    prompt=options.prompt)
  File "C:\Python27\lib\site-packages\virtualenv.py", line 647, in create_environment
    site_packages=site_packages, clear=clear))
  File "C:\Python27\lib\site-packages\virtualenv.py", line 771, in install_python
    copy_required_modules(home_dir)
  File "C:\Python27\lib\site-packages\virtualenv.py", line 725, in copy_required_modules
    dst_filename = change_prefix(filename, dst_prefix)
  File "C:\Python27\lib\site-packages\virtualenv.py", line 710, in change_prefix
    (filename, prefixes)
AssertionError: Filename c:\Python27\Lib\os.py does not start with any of these prefixes: ['C:\\Python27']

I have the following environment variables:

PYTHONHOME=C:\Python27
PYTHONPATH=c:\Python27;c:\Python27\Lib
PYTHONSTARTUP=C:\Users\Larry\.pythonrc
PATH=%PYTHONHOME%\;%PYTHONHOME%\Scripts;etc

Installed ActiveState Python:

ActivePython 2.7.2.5 (ActiveState Software Inc.) based on
Python 2.7.2 (default, Jun 24 2011, 12:21:10) [MSC v.1500 32 bit (Intel)] on win32

I updated the PYTHONPATH=C:\Python27;C:\Python27\Lib Still looking for a solution, I found and removed AppData/Python*. Reinstalled Python and now have a different error:

C:\xbz>virtualenv _t
PYTHONHOME is set.  You *must* activate the virtualenv before using it
Overwriting _t\Lib\site.py with new content
New python executable in _t\Scripts\python2.7.exe
Not overwriting existing python script _t\Scripts\python.exe (you must use _t\Scripts\python2.7.exe)
Overwriting _t\Lib\distutils\__init__.py with new content
Installing setuptools..............
  Complete output from command C:\xbz\_t\Scripts\python2.7.exe -c "#!python
\"\"\"Bootstrap setuptoo...


" --always-copy -U setuptools:
  Traceback (most recent call last):
  File "<string>", line 278, in <module>
  File "<string>", line 210, in main
  File "<string>", line 132, in download_setuptools
  File "C:\Python27\Lib\urllib2.py", line 94, in <module>
    import httplib
  File "C:\Python27\Lib\httplib.py", line 71, in <module>
    import socket
  File "C:\Python27\Lib\socket.py", line 47, in <module>
    import _socket
ImportError: No module named _socket
----------------------------------------
...Installing setuptools...done.
Traceback (most recent call last):
  File "C:\Python27\Scripts\virtualenv-script.py", line 9, in <module>
    load_entry_point('virtualenv==1.5.2', 'console_scripts', 'virtualenv')()
  File "C:\Python27\lib\site-packages\virtualenv.py", line 558, in main
    prompt=options.prompt)
  File "C:\Python27\lib\site-packages\virtualenv.py", line 654, in create_environment
    install_setuptools(py_executable, unzip=unzip_setuptools)
  File "C:\Python27\lib\site-packages\virtualenv.py", line 384, in install_setuptools
    _install_req(py_executable, unzip)
  File "C:\Python27\lib\site-packages\virtualenv.py", line 360, in _install_req
    cwd=cwd)
  File "C:\Python27\lib\site-packages\virtualenv.py", line 624, in call_subprocess
    % (cmd_desc, proc.returncode))
OSError: Command C:\xbz\_t\Scripts\python2.7.exe -c "#!python
\"\"\"Bootstrap setuptoo...




" --always-copy -U setuptools failed with error code 1

I hacked Lib/socket.py and inserted:

import sys
sys.path = ['', 'C:\\Python27\\lib\\site-packages\\dotcloud-0.3.1-py2.7.egg', 'C:\\Python27\\lib\\site-packages\\dotcloud.cli-0.3.1-py2.7.egg', 'C:\\Python27\\lib\\site-packages\\flask-0.7dev_20110622-py2.7.egg', 'C:\\Python27\\lib\\site-packages\\werkzeug-0.6.2-py2.7.egg', 'C:\\Python27\\lib\\site-packages\\gunicorn-0.12.2-py2.7.egg', 'C:\\Python27\\lib\\site-packages\\wtforms-0.6.3-py2.7.egg', 'C:\\Python27\\lib\\site-packages\\repoze.browserid-0.3-py2.7.egg', 'C:\\Python27\\lib\\site-packages\\paste-1.7.5.1-py2.7.egg', 'C:\\Python27\\lib\\site-packages\\django_pjax-1.0-py2.7.egg', 'C:\\Python27\\lib\\site-packages\\paramiko-1.7.7.1-py2.7.egg', 'C:\\Python27\\lib\\site-packages\\pycrypto-2.4.1-py2.7-win32.egg', 'C:\\Python27', 'C:\\Python27\\Lib', 'C:\\Windows\\system32\\python27.zip', 'C:\\Python27\\DLLs', 'C:\\Python27\\lib\\plat-win', 'C:\\Python27\\lib\\lib-tk', 'C:\\Python27\\lib\\site-packages', 'C:\\Python27\\lib\\site-packages\\PIL', 'C:\\Python27\\lib\\site-packages\\win32', 'C:\\Python27\\lib\\site-packages\\win32\\lib', 'C:\\Python27\\lib\\site-packages\\Pythonwin', 'C:\\Python27\\lib\\site-packages\\setuptools-0.6c11-py2.7.egg-info', 'C:\\Python27\\Scripts', 'C:\\Python27\\Lib\\site-packages\\django\\bin']

Above

import _socket

The reason was that I was able to import socket from straight python prompt! So stuffed my existing path. I haven't narrowed down exactly which directory made it happy. It at least will reveal to someone else why I am getting the error without it.

Ideas? Suggestions? Thank you. :)


I hacked Lib/socket.py and inserted:

import sys
sys.path.append('C:\\Python27\\DLLs')

Above

import _socket
share improve this question
 
 
Check with this question stackoverflow.com/questions/4527958/python-virtualenv-questions –  Zain Khan  Dec 31 '11 at 14:48
 
Still looking for a solution, I found and removed AppData/Python*. Reinstalled Python and now have a different error. See updated original question. –  Larry Eitel  Jan 4 '12 at 21:30 
 
I found a workaround involving hacking C:\Python27\Lib\socket.py. See about. –  Larry Eitel  Jan 25 '12 at 23:36 
 
I've filed this as a bug: github.com/pypa/virtualenv/issues/815. –  Martijn Pieters♦  Nov 3 '15 at 16:45

11 Answers

Try to set PYTHONPATH to PYTHONPATH=C:\Python27;C:\Python27\Lib (uppercase C at the start).

This can be done at the command prompt by typing set PYTHONPATH=C:\Python27;C:\Python27\Lib.

PYTHONPATH will revert back to whatever it previously was once that command prompt window is closed.

share improve this answer
 
 
Sorry but that didn't help. :( –  Larry Eitel  Jan 1 '12 at 23:22
 
It did this time. :) Thank you :) –  Larry Eitel  Oct 9 '12 at 20:45

3 year old question, but hopefully this answer can still help someone. Rather than setting the environment variables (which mysteriously didn't work for me), you can pass the path to your Python installation when setting up the virtual environment. In Windows, you have to path out to python.exe, but it seems that in Linux/OS X you just path to the folder. Examples:

Windows:

virtualenv -p <PATH TO PYTHON.EXE> venv

Linux/Mac:

virtualenv -p </user/path/to/python> venv

Both create a virtual environment in subfolder "venv" in current directory.

share improve this answer
 

For the _socket error, change your pythonpython path to:

PYTHONPATH=C:\Python27;C:\Python27\Lib;C:\Python27\DLLs
share improve this answer
 

Its strange but from the error message

AssertionError: Filename c:\Python27\Lib\os.py does not start with any of these prefixes: ['C:\\Python27']

It seems, it expects the path-name for the file os.py to start with upper case 'C' and the prefix sanity check is case sensitive.

As the path to the library is derived from PYTHONPATH and in your case the drive letter is in lower case, it seems logical to change it to upper case to resolve the issue.

like

PYTHONPATH=C:\Python27;C:\Python27\Lib
share improve this answer
 
 
I had this same issue. Just to reiterate, you have to look at the error message and make sure that the /case/ of all the letters in the path setting match the error message. Also, after you change the PATH settings, you have to start a new command prompt before the new settings will be used. –  hazzey  Jul 18 '14 at 13:30

I hate "summary" answers, but as I just went through a very similar issue I thought I would post my solution here as well which draws from several of these answers.

The assert error was caused because I did not have a PYTHONPATH environment variable setup.

The socket error was caused because I did not include the PythonXX\DLLs folder.

The full PYTHONPATH environment variable should look follows:

PYTHONPATH=C:\Python27;C:\Python27\Lib;C:\Python27\DLLs
share improve this answer
 

I have added

if is_win:    
        prefixes.append('C:\PYTHON27')    

to virtualenv.py and it works.

share improve this answer
 

I also ran into this problem on Windows 7. My Python27 installation was under C:\Program Files, which obviously contains a space in the path. So, on a separate Windows 7 system that did not contain Python, I did a fresh install of Python27 under C:\Python27 (the default installation path), followed by an install of setuptools (for easy_install).

Afterwards, I was able to install virtualenv CLEANLY without the above assertion error (I used easy_install).

I know that the OP's system is already using the default path, but I thought I would add my experience here as a possible solution for certain specific cases.

share improve this answer
 

This issue is presumably a hangover from other more case-sensitive file systems.

Complete solution:

  1. Read the error message from virtualenv. Remember the part where it says "does not start with any of these prefixes: ['C:\\Python27']".

  2. Edit PYTHONPATH, or create it if you don't have one (Start+Break, Advanced system settings, Environment Variables). It shouldn't matter if it's a user variable or a system variable, unless you plan to switch user accounts.

  3. Make the case match the error message. BOTH the drive letter AND the folder name must match (presumably intermediate folders as well, if you didn't install to C:\Python27). You can ignore the double backslash, one is fine.

The only change I made to fix the bug was as follows. The change should take effect for any new command / terminal sessions (close your open cmd.exe / powershell / etc. windows).

  • Old state: PYTHONPATH = C:\PYTHON27;C:\PYTHON27\LIB;C:\PYTHON27\DLLS

  • New state: PYTHONPATH = C:\Python27;C:\Python27\LIB;C:\Python27\DLLS

If you have any other items in your PYTHONPATH, you might as well change those too, but it probably won't affect virtualenv's ability to run.

share improve this answer
 

Change "virtualenv.py" --> change_prefix with:

def change_prefix(filename, dst_prefix):
  ...
 prefixes = sorted(prefixes, key=len, reverse=True)
 filename = str(os.path.abspath(filename))[0].lower() + str(os.path.abspath(filename))[1:]
 for src_prefix in prefixes:
    if filename.startswith(src_prefix):
        _, relpath = filename.split(src_prefix, 1)
        if src_prefix != os.sep: # sys.prefix == "/"
            assert relpath[0] == os.sep
            relpath = relpath[1:]
        return join(dst_prefix, relpath)
 assert False, "Filename %s does not start with any of these prefixes: %s" % \
    (filename, prefixes)

  ...
share improve this answer
 

I had the same assertion error from a slightly different cause. The error was does not start with any of these prefixes: ['C:\\python27'] and note the lowercase "p". The actual folder names all use capital-P Python27. All the prefixes in PTYHONPATH were correct. However I had entered the PYTHONHOME variable as C:\python27 and although this was fine for Python, it caused the error in virtualenv.

share improve this answer
 

This is an error already submitted to the Python development team:https://github.com/pypa/virtualenv/pull/697

In the meanwhile why not just change the Python installation folder name to (ptyhon27) to make the assertion work, or if you feel more confortable with that just reinstall python using the alternative location. It works with no issue.

share improve this answer
Dismiss
Announcing Stack Overflow Documentation

We started with Q&A. Technical documentation is next, and we need your help.

Whether you're a beginner or an experienced developer, you can contribute.

Sign up and start helping →  Learn more about Documentation →

Having trouble with virtualenv on Windows 7.

I run:

virtualenv _testenv

It returns:

Traceback (most recent call last):
  File "C:\Python27\Scripts\virtualenv-script.py", line 9, in <module>
    load_entry_point('virtualenv==1.5.2', 'console_scripts', 'virtualenv')()
  File "C:\Python27\lib\site-packages\virtualenv.py", line 558, in main
    prompt=options.prompt)
  File "C:\Python27\lib\site-packages\virtualenv.py", line 647, in create_environment
    site_packages=site_packages, clear=clear))
  File "C:\Python27\lib\site-packages\virtualenv.py", line 771, in install_python
    copy_required_modules(home_dir)
  File "C:\Python27\lib\site-packages\virtualenv.py", line 725, in copy_required_modules
    dst_filename = change_prefix(filename, dst_prefix)
  File "C:\Python27\lib\site-packages\virtualenv.py", line 710, in change_prefix
    (filename, prefixes)
AssertionError: Filename c:\Python27\Lib\os.py does not start with any of these prefixes: ['C:\\Python27']

I have the following environment variables:

PYTHONHOME=C:\Python27
PYTHONPATH=c:\Python27;c:\Python27\Lib
PYTHONSTARTUP=C:\Users\Larry\.pythonrc
PATH=%PYTHONHOME%\;%PYTHONHOME%\Scripts;etc

Installed ActiveState Python:

ActivePython 2.7.2.5 (ActiveState Software Inc.) based on
Python 2.7.2 (default, Jun 24 2011, 12:21:10) [MSC v.1500 32 bit (Intel)] on win32

I updated the PYTHONPATH=C:\Python27;C:\Python27\Lib Still looking for a solution, I found and removed AppData/Python*. Reinstalled Python and now have a different error:

C:\xbz>virtualenv _t
PYTHONHOME is set.  You *must* activate the virtualenv before using it
Overwriting _t\Lib\site.py with new content
New python executable in _t\Scripts\python2.7.exe
Not overwriting existing python script _t\Scripts\python.exe (you must use _t\Scripts\python2.7.exe)
Overwriting _t\Lib\distutils\__init__.py with new content
Installing setuptools..............
  Complete output from command C:\xbz\_t\Scripts\python2.7.exe -c "#!python
\"\"\"Bootstrap setuptoo...


" --always-copy -U setuptools:
  Traceback (most recent call last):
  File "<string>", line 278, in <module>
  File "<string>", line 210, in main
  File "<string>", line 132, in download_setuptools
  File "C:\Python27\Lib\urllib2.py", line 94, in <module>
    import httplib
  File "C:\Python27\Lib\httplib.py", line 71, in <module>
    import socket
  File "C:\Python27\Lib\socket.py", line 47, in <module>
    import _socket
ImportError: No module named _socket
----------------------------------------
...Installing setuptools...done.
Traceback (most recent call last):
  File "C:\Python27\Scripts\virtualenv-script.py", line 9, in <module>
    load_entry_point('virtualenv==1.5.2', 'console_scripts', 'virtualenv')()
  File "C:\Python27\lib\site-packages\virtualenv.py", line 558, in main
    prompt=options.prompt)
  File "C:\Python27\lib\site-packages\virtualenv.py", line 654, in create_environment
    install_setuptools(py_executable, unzip=unzip_setuptools)
  File "C:\Python27\lib\site-packages\virtualenv.py", line 384, in install_setuptools
    _install_req(py_executable, unzip)
  File "C:\Python27\lib\site-packages\virtualenv.py", line 360, in _install_req
    cwd=cwd)
  File "C:\Python27\lib\site-packages\virtualenv.py", line 624, in call_subprocess
    % (cmd_desc, proc.returncode))
OSError: Command C:\xbz\_t\Scripts\python2.7.exe -c "#!python
\"\"\"Bootstrap setuptoo...




" --always-copy -U setuptools failed with error code 1

I hacked Lib/socket.py and inserted:

import sys
sys.path = ['', 'C:\\Python27\\lib\\site-packages\\dotcloud-0.3.1-py2.7.egg', 'C:\\Python27\\lib\\site-packages\\dotcloud.cli-0.3.1-py2.7.egg', 'C:\\Python27\\lib\\site-packages\\flask-0.7dev_20110622-py2.7.egg', 'C:\\Python27\\lib\\site-packages\\werkzeug-0.6.2-py2.7.egg', 'C:\\Python27\\lib\\site-packages\\gunicorn-0.12.2-py2.7.egg', 'C:\\Python27\\lib\\site-packages\\wtforms-0.6.3-py2.7.egg', 'C:\\Python27\\lib\\site-packages\\repoze.browserid-0.3-py2.7.egg', 'C:\\Python27\\lib\\site-packages\\paste-1.7.5.1-py2.7.egg', 'C:\\Python27\\lib\\site-packages\\django_pjax-1.0-py2.7.egg', 'C:\\Python27\\lib\\site-packages\\paramiko-1.7.7.1-py2.7.egg', 'C:\\Python27\\lib\\site-packages\\pycrypto-2.4.1-py2.7-win32.egg', 'C:\\Python27', 'C:\\Python27\\Lib', 'C:\\Windows\\system32\\python27.zip', 'C:\\Python27\\DLLs', 'C:\\Python27\\lib\\plat-win', 'C:\\Python27\\lib\\lib-tk', 'C:\\Python27\\lib\\site-packages', 'C:\\Python27\\lib\\site-packages\\PIL', 'C:\\Python27\\lib\\site-packages\\win32', 'C:\\Python27\\lib\\site-packages\\win32\\lib', 'C:\\Python27\\lib\\site-packages\\Pythonwin', 'C:\\Python27\\lib\\site-packages\\setuptools-0.6c11-py2.7.egg-info', 'C:\\Python27\\Scripts', 'C:\\Python27\\Lib\\site-packages\\django\\bin']

Above

import _socket

The reason was that I was able to import socket from straight python prompt! So stuffed my existing path. I haven't narrowed down exactly which directory made it happy. It at least will reveal to someone else why I am getting the error without it.

Ideas? Suggestions? Thank you. :)


I hacked Lib/socket.py and inserted:

import sys
sys.path.append('C:\\Python27\\DLLs')

Above

import _socket
share improve this question
 
   
Check with this question stackoverflow.com/questions/4527958/python-virtualenv-questions –  Zain Khan  Dec 31 '11 at 14:48
   
Still looking for a solution, I found and removed AppData/Python*. Reinstalled Python and now have a different error. See updated original question. –  Larry Eitel  Jan 4 '12 at 21:30 
   
I found a workaround involving hacking C:\Python27\Lib\socket.py. See about. –  Larry Eitel  Jan 25 '12 at 23:36 
   
I've filed this as a bug: github.com/pypa/virtualenv/issues/815. –  Martijn Pieters♦  Nov 3 '15 at 16:45

11 Answers

Try to set PYTHONPATH to PYTHONPATH=C:\Python27;C:\Python27\Lib (uppercase C at the start).

This can be done at the command prompt by typing set PYTHONPATH=C:\Python27;C:\Python27\Lib.

PYTHONPATH will revert back to whatever it previously was once that command prompt window is closed.

share improve this answer
 
   
Sorry but that didn't help. :( –  Larry Eitel  Jan 1 '12 at 23:22
   
It did this time. :) Thank you :) –  Larry Eitel  Oct 9 '12 at 20:45

3 year old question, but hopefully this answer can still help someone. Rather than setting the environment variables (which mysteriously didn't work for me), you can pass the path to your Python installation when setting up the virtual environment. In Windows, you have to path out to python.exe, but it seems that in Linux/OS X you just path to the folder. Examples:

Windows:

virtualenv -p <PATH TO PYTHON.EXE> venv

Linux/Mac:

virtualenv -p </user/path/to/python> venv

Both create a virtual environment in subfolder "venv" in current directory.

share improve this answer
 

For the _socket error, change your pythonpython path to:

PYTHONPATH=C:\Python27;C:\Python27\Lib;C:\Python27\DLLs
share improve this answer
 

Its strange but from the error message

AssertionError: Filename c:\Python27\Lib\os.py does not start with any of these prefixes: ['C:\\Python27']

It seems, it expects the path-name for the file os.py to start with upper case 'C' and the prefix sanity check is case sensitive.

As the path to the library is derived from PYTHONPATH and in your case the drive letter is in lower case, it seems logical to change it to upper case to resolve the issue.

like

PYTHONPATH=C:\Python27;C:\Python27\Lib
share improve this answer
 
   
I had this same issue. Just to reiterate, you have to look at the error message and make sure that the /case/ of all the letters in the path setting match the error message. Also, after you change the PATH settings, you have to start a new command prompt before the new settings will be used. –  hazzey  Jul 18 '14 at 13:30

I hate "summary" answers, but as I just went through a very similar issue I thought I would post my solution here as well which draws from several of these answers.

The assert error was caused because I did not have a PYTHONPATH environment variable setup.

The socket error was caused because I did not include the PythonXX\DLLs folder.

The full PYTHONPATH environment variable should look follows:

PYTHONPATH=C:\Python27;C:\Python27\Lib;C:\Python27\DLLs
share improve this answer
 

I have added

if is_win:    
        prefixes.append('C:\PYTHON27')    

to virtualenv.py and it works.

share improve this answer
 

I also ran into this problem on Windows 7. My Python27 installation was under C:\Program Files, which obviously contains a space in the path. So, on a separate Windows 7 system that did not contain Python, I did a fresh install of Python27 under C:\Python27 (the default installation path), followed by an install of setuptools (for easy_install).

Afterwards, I was able to install virtualenv CLEANLY without the above assertion error (I used easy_install).

I know that the OP's system is already using the default path, but I thought I would add my experience here as a possible solution for certain specific cases.

share improve this answer
 

This issue is presumably a hangover from other more case-sensitive file systems.

Complete solution:

  1. Read the error message from virtualenv. Remember the part where it says "does not start with any of these prefixes: ['C:\\Python27']".

  2. Edit PYTHONPATH, or create it if you don't have one (Start+Break, Advanced system settings, Environment Variables). It shouldn't matter if it's a user variable or a system variable, unless you plan to switch user accounts.

  3. Make the case match the error message. BOTH the drive letter AND the folder name must match (presumably intermediate folders as well, if you didn't install to C:\Python27). You can ignore the double backslash, one is fine.

The only change I made to fix the bug was as follows. The change should take effect for any new command / terminal sessions (close your open cmd.exe / powershell / etc. windows).

  • Old state: PYTHONPATH = C:\PYTHON27;C:\PYTHON27\LIB;C:\PYTHON27\DLLS

  • New state: PYTHONPATH = C:\Python27;C:\Python27\LIB;C:\Python27\DLLS

If you have any other items in your PYTHONPATH, you might as well change those too, but it probably won't affect virtualenv's ability to run.

share improve this answer
 

Change "virtualenv.py" --> change_prefix with:

def change_prefix(filename, dst_prefix):
  ...
 prefixes = sorted(prefixes, key=len, reverse=True)
 filename = str(os.path.abspath(filename))[0].lower() + str(os.path.abspath(filename))[1:]
 for src_prefix in prefixes:
    if filename.startswith(src_prefix):
        _, relpath = filename.split(src_prefix, 1)
        if src_prefix != os.sep: # sys.prefix == "/"
            assert relpath[0] == os.sep
            relpath = relpath[1:]
        return join(dst_prefix, relpath)
 assert False, "Filename %s does not start with any of these prefixes: %s" % \
    (filename, prefixes)

  ...
share improve this answer
 

I had the same assertion error from a slightly different cause. The error was does not start with any of these prefixes: ['C:\\python27'] and note the lowercase "p". The actual folder names all use capital-P Python27. All the prefixes in PTYHONPATH were correct. However I had entered the PYTHONHOME variable as C:\python27 and although this was fine for Python, it caused the error in virtualenv.

share improve this answer
 

This is an error already submitted to the Python development team:https://github.com/pypa/virtualenv/pull/697

In the meanwhile why not just change the Python installation folder name to (ptyhon27) to make the assertion work, or if you feel more confortable with that just reinstall python using the alternative location. It works with no issue.

share improve this answer
reading-set 阅读集 立即下载

相关推荐

海鸥派OpenEuler开发板实战:从烧写到SSH连接的完整指南

本文提供海鸥派OpenEuler开发板从开箱到SSH远程连接的完整实战指南。详细介绍了基于海思SD3403/SS928芯片的算力开发板系统烧写、存储扩容、网络配置等关键步骤,帮助开发者快速上手这款AI边缘计算设备,并实现高效的远程开发与管理。

ruby5的博客 1121

Python的环境变量设置、虚拟环境、包加载

包的调用 (1)将模块中所有的数据赋值给模块名,调用时需要模块名.方法名 import 模块名 ===》 (2)将该方法单独放到当前文件运行一遍,调用时只需要方法名()即可运行 from 模块名 import 方法名 ==》 导入一个包 就是执行包下的__init__.py文件。 导入系统环境设置包 import sys,os 获取当前文件的全名 os.path.abspath(__fil...

dltan 3402

判断两个多边形是否相交(java实现)

判断两个多边形是否相交 ,当前认为一个点相交也是相交,可针对凹多边形和凸边型等多复杂的多边形进行相交判断,采用java实现,因为网上java实现的比较少,所以这里写下如何实现,适用于碰撞检测,地图等等应用场景

IT_CREATE的博客 5845

python的virtualenv报错C:\Python27\Lib\os.py does not start with any of these prefixes: ['C:\\python27']

使用python的virtualenv创建一个名字为envname的虚拟环境时报错如图: 寻找很多资料后解决,却是python的默认安装路径形成的path导致的问题 错误是does not start with any of these prefixes:['C:\\python27']并注意小写字母“p”。实际的文件夹名称都使用大写字母-P Python27。 PTYHONPATH中的所...

qq_41714308的博客 1098

Metal ECO实战:如何在不修改底层掩模的情况下修复芯片时序问题

本文深入探讨了Metal ECO技术在芯片设计中的应用,这是一种在不修改底层晶体管掩模的前提下,仅通过调整金属连线和替换预置填充单元来修复时序问题的“微创手术”。文章详细解析了其原理、适用场景、关键操作流程与命令,并分享了实战中的高级技巧与常见陷阱,为面临流片前时序违例的工程师提供了宝贵的修复指南。

wdx0123456的博客 431

程序进入hardfault之后查找原因的方法

如果在MCU运行程序的时候,进入了hardfault,该怎么办?

smart_boy__的博客 761

assertionerror解决 python_【已解决】virtualenv报错AssertionError | 勤奋的小青蛙

virtualenv新建环境时报错:AssertionError: Filename D:\Python34\Lib\os.py does not start with any of these prefixes: ['D:\\python34', 'D:\\python34']E:\flasky>virtualenv venvUsing base prefix 'd:\\python34'...

weixin_39820244的博客 3698

基于51单片机的智能花盆灌溉系统设计与实现

本文详细介绍了基于51单片机的智能花盆灌溉系统设计与实现,通过DS18B20温度传感器、土壤湿度传感器和LCD1602显示屏等硬件模块,结合精确的算法控制,实现自动监测与灌溉。系统解决了传统灌溉依赖定时器、缺乏可视化界面的问题,适合上班族、园艺爱好者和植物园工作人员使用,有效提升植物养护效率。

honey的博客 1015

Flask 环境变量 FLASK_ENV 说明

FLASK_ENV FLASK_ENV 变量用来告诉Flask当前应用所运行的环境,有两个值,分别是 “production” 和 “development”,默认缺省值是“production”。 Flask自身和第三方扩展插件可能会基于此变量值改变自己的行为。 如果设置为:“development”,那么可实现: 1、激活调试器。 2、激活自动重载。 3、打开 Flask 应用的调试模式。 只要项目中代码有发生变化,程序就会自动重启。 在开发调试过程中很有用,如果是production,每次还

Henry_Wu001的专栏 8596

Qupath软件的安装与使用

Qupath软件的安装与使用软件安装软件下载软件安装【windows版】简单使用文件打开人工标注标注导出和导入 Qupath是一款开源的医学图像标注软件,适合放射影像及数字病理切片等的查看。同时,其自带的标注功能使得医生可以直接通过该软件进行病变区域的标注和分类。跟进一步的,该软件提供groovy脚本运行接口,可供操作者编写和运行脚本,将标注信息转换为xml或者json格式的数据进行进一步的后序处...

qq_40662074的博客 3万+

《多模态融合改进》支持目标检测、目标分割、OBB、姿态估计,配置教程

本文以为例,讲解如何配置,支持替换专栏里所有的改进方式。

Limiiiing的博客 801

Flask框架

Flask诞生于2010年,是Armin ronacher(人名)用 Python 语言基于 Werkzeug 工具箱编写的轻量级Web开发框架。 Flask 本身相当于一个内核,其他几乎所有的功能都要用到扩展(邮件扩展Flask-Mail,用户认证Flask-Login,数据库Flask-SQLAlchemy),都需要用第三方的扩展来实现。比如可以用 Flask 扩展加入ORM、窗体验证工具,文件上传、身份验证等。Flask 没有默认使用的数据库,你可以选择 MySQL,也可以用 NoSQ

有用的话关个注,点个赞,收个藏🫶。 2082

Vue2 - 详细实现解析Markdown内容生成侧边栏Toc目录索引,识别文章内容根据大标题/小标题自动生成多级文章目录,点击目录导航时跳转到文章内容对应的锚点位置带过渡动画,滑过锚点时高亮对应标题

vue2,nuxt2,Markdown,目录,文章目录锚点,滚动高亮导航文字,根据页面滚动高亮显示目录的侧边栏,自动提取标题生成右侧目录,vuemarkdown解析并生成目录,滚动页面的时候文章目录跟着选中效果,侧边栏滚动跟随页面,右边目录固定,左边内容可以滚动并且与左边目录联动,实现监听滚动,锚点定位,文章目录滚动跟随高亮,右边菜单点击目录滚动到对应标题,报错,渲染失败,文章内容,读取#标题符号,自动生成一个目录树,自动生成Toc目录,博客内容生成目录索引,资讯文章,生成锚点目录树TOC,详细示例代码教

🏆 前端领域优质创作者 3670

flask基础学习

Flask中有个配置属性叫做SECRET_KEYregex名字固定"""第一步:自定义URL匹配正则表达式""""""路由匹配时,正则匹配成功后传递给视图函数中参数的值:return:""""""使用url_for反向生成URL时,传递的参数经过该方法处理,返回的值用于生成URL中的参数:return:"""return val# 第二步:添加到flask中# 第三步:zaiapp.run()Mobile转换器# 等价于# 定义转换器# 将自定义转换器告知Flask应用。

happy_king_zi的博客 1571

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

Flask框架用法笔记

是一个Python编写的Web 微框架,让我们可以使用Python语言快速实现一个网站或Web服务。本文参考自,英文不好的同学也可以参考。

m0_70694811的博客 1681

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

Flask快速入门

Django(MVT)&Flask(轻量级,代码多,类比Java的SpringMVC) 主要实现了路由分发和模板渲染功能 启动 方式一run 方式二配置export FLASK_APP = 当前路径下的文件名。 export FLSK_ENV = development flask run -h ip地址 -p 端口号 结果:返回一个Map类,类中是一个列表,列表分为三部分:路由,请求方式,视图。注意:@app.route(‘/’, methods=[‘get’, ‘POST’]) 路由转化器 自定义转化

m0_52712579的博客 1058

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

flask 启动服务

flask run --help获取帮助 1.环境变量 FLASK_APP 指明flask的启动实例 $ export FLASK_APP=helloworld $ flask run * Running on http://127.0.0.1:5000/ 2.绑定地址 端口 flask run -h 0.0.0.0 -p 8000 3.生产模式与开发模式的控制 通过FLASK_ENV环境变量指明 export FLASK_ENV=production 运行在生产模式,未指明则默认为此方式 export

Claroja 2678

Flask+flask-socketio+jsonrpc组合配置避坑

Flask+flask-socketIO+jsonrpc这种组合能被我套出来也是离谱,事先声明:出现这种组合是因为本人之前对flask框架的使用仅限于flask+jsonrpc,所以导致这种情况出现,其实flask还可以加Flask-Restful实现,至于如何使用全凭读者根据业务需求自行裁决。 我之随意写这篇文章是有原因的,就是部署的时候由于配置文件会给自己埋下许多坑,百度查不到具体的解决方法,只能自己一点点摸索 一、起源 说起这个就很danTeng,刚离开北京来到成都,就职于一家四十多人的小外包公司,大

有用的话关个注,点个赞,收个藏🫶。 1173

使用 Flask + Flask RESTful 快速搭建 API 服务

使用 Flask + Flask RESTful 搭建 API 应用并使用 Blueprint(蓝图) 管理 API;使用扩展实现 ORM 操作 MySQL 数据库;基于 JWT 验证实现注册、登录以及登出接口;实现一个最基本的列表获取接口;解决跨域问题;使用 Docker 部署该应用。在正式开始之前,请确保你已经安装了 Python,并且对 Python 有一定了解。

aobulaien001的博客 1584

从 Flask-Script 迁移到 Flask-CLI

一、Flask-Script 已经消亡! 曾几何时 Flask-Script 一直都是配合 Flask 应用的利器,你可以在命令行启动项目,还可以配合 Flask-Migrate 做数据迁移,这两个工具一度成为 Flask 项目的必备选项:Flask 组件 Script、Flask 组件 Migrate。 但 Flask 从 0.11 开始就内置了 CLI 工具,所有连 Flask-Script 作者都觉得 Flask-Script 没必要在维护下去了。GitHub 上也已经归档了:https://gith

极客点儿 2027

Flask生态:Flask-RESTful、Flask-Admin、Flask-SocketIO、Flask-SQLAlchemy、Flask-MonitoringDashboard

Flask生态:Flask-RESTful、Flask-Admin、Flask-SocketIO、Flask-SQLAlchemy、Flask-MonitoringDashboard

lonelymanontheway的博客 226

如何在Flask项目中部署Flask-Blogging:从安装到上线的简单步骤

Flask-Blogging是一个基于Markdown的Python博客引擎,作为Flask扩展,它能轻松为你的Web应用添加专业的博客功能。本文将带你通过简单步骤完成从安装到上线的全过程,让你快速拥有一个功能完善的博客系统。 ## 准备工作:环境与依赖 在开始之前,请确保你的环境满足以下要求: - Python 3.7及以上版本 - 已安装Flask框架 - 虚拟环境(推荐使用venv或vi

gitblog_00084的博客 612

04-Flask-新版Flask运行方式

Flask-新版Flask运行方式

小白的博客 1222

flask安装及配置解释

IDIE :pycharm2019 python -version :python3.7.3 os:windows10 一、从控制台安装 跟随Flask的中文文档安装时,通过cmd命令行操作的 过程较难理解 在一个合适的位置建立一个项目文件夹 项目文件地址:F:\Python\flask_project 创建虚拟环境 为什么需要创建虚拟环境: 因为不同的python项目需要不同版本的python库...

Dean_xiu的博客 1754

【Flask】带你快速入门Flask

Flask 介绍 Flask 是一个轻量级的 Web 应用框架, 使用 Python 编写。 基于 Werkzeug WSGI 工具箱和 Jinja2 模板引擎。使用 BSD 授权。 Flask 也被称为 microframework ,因为它使用简单的核心,用 extension 增加其它功能。 Flask 没有默认使用的数据库、窗体验证工具。 然而,Flask 保留了扩增的弹性,可以用 Flask-extension 加入这些功能:ORM、窗体验证工具、文件上传、各种开放式身份验证技术。 当安装 Fla

Create value with coding 1万+
上一篇: 高并发异步uwsgi+web.py+gevent
下一篇: 打印堆栈
linuxheik
博客等级 码龄15年 865粉丝 135原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值