Папка scripts для python

Is there a standard installation location for scripts?

I’m deploying a bunch of python scripts to my build, test and soon production server. It can be nodejs or any other thing I want to run under nginx so the location should be generic rather than specific to the type of script. The files deployed are coming from the the build server artifacts and all versions (build, test and maybe also production) should reside on the same server so using a default folder is not an option as the builds would overwrite each other. The intention is to keep a complete installation contained in one folder per build no matter what type of script it is. Folder could look something like this:

/usr /local /build /www /python /nodejs /test /www /python /nodejs 

Is there a preferred location on linux where the root of each build installation should reside? I have seen /usr/local mentioned but am not sure it is the one to use.

Standard or prefered location? Well, generally speaking, there is no standard installation location for scripts.

@RaduRădeanu Sure there is. Commands (whether it’s compiled binaries, perl scripts, python scripts, shell scripts, etc) go in /usr/bin , /usr/local/bin , etc.

@geirha scripts != binaries; whois perl != whois python ; shell scripts can be found in many places. So, what’s the standard?

@RaduRădeanu A lot of the commands in /bin and /usr/bin (in Ubuntu) are scripts. Commands can be written in whatever language you like, more or less, including scripting languages. Try running file /usr/bin/* | grep script

Читайте также:  Пример работы CSS

Источник

Understanding The Python Root Folder

For people new to Python, locating Python files for development can be confusing; these can be python.exe, the scripts folder or the location of where modules are installed to. In this post, I discuss what folders host what and how to track common things down.

Locating Your Installation

When first installing Python, depending on what you select in the installation, there are a couple of places Python could be installed (you could also select your own directory). Luckily this can be easily found by executing the following in Python:

import sys print(sys.executable) 

This will print the location of python.exe which is the executable that runs Python scripts. Common places for Python to be installed on is in C:\PythonXY or %AppData%\Roaming\Python\PythonXY .

To run Python scripts, you need to pass a filename as an argument to python.exe so python.exe can run it. For example, if you wanted to execute myscript.py, you would call python myscript.py which calls python.exe (regarding it can be found on the PATH) and passes the filename «myscript.py» as an argument.

Where you located python.exe is also the root of your Python installation (assuming you aren’t using a virtual environment). In this folder, you will find files relating directly to Python and modules you have installed. Under the headings below, I’m going to explain what is in each of the folders in the root folder and notable subdirectories in them.

Before we start looking at the folders, you should notice there is a python.exe and a pythonw.exe file. These do very similar jobs but have one primary difference, python.exe will open a terminal window whereas pythonw.exe will not.

Typically .py files are associated with python.exe and .pyw files are associated with pythonw.exe . This means if you want to see the output from your script (like print calls) or just want to know it’s running by seeing a window open, then use .py , otherwise, you will want to use .pyw to hide the terminal window that appears.

Here is a writeup of the smaller differences between them.

The folder DLLs/ contains DLL files relating to Python. When looking in here, you may notice that there are actually .pyd files in here.

.pyd files are actually the same as DLL files but they include a function PyInit_MODULE() where «MODULE» is the name of the DLL file (without the extension). You can read more about this in the docs.

The folder include/ contains header files for the Python/C API

The folder Lib/ contains the Python standard library; that is, all the modules that come with Python like csv , io , tkinter , re and many others.

A very notable folder in this folder is site-packages . This is where Python modules are installed when you install them using pip or a setup.py file. Looking in this folder for a module you want to investigate can allow you to see the source.

If you import a Python module in a Python script and then print the module, the path output will typically be in this folder; for example:

For me outputs . C:/Python36 is where Python is installed for me and you can see flask is sitting in lib/site-packages.

The folder libs/ contains native code libraries in comparison to Lib/ . This means whereas most files in Lib/ are human-readable, libs/ typically contains compiled libraries.

Here is a bit more information on this folder.

The folder Scripts/ contains executables and other «scripts» that can be run. Typically this is where modules will put executables so they are then located in the terminal/OS calls using the PATH variables.

Putting executables in here allows us to easily execute a command which will be looked for in here (regarding this folder is in the PATH variable) and then executed. If you set console scripts in a setup.py file, the names you specify will be created as executables in here.

Here is an example of a console script that I mentioned. This allows you to call auto-py-to-exe on the command line to start the application.

The folder tcl/ contains tkinter source files as tkinter runs on tcl.

When packaging Python to an executable, you might find some files from here in the result folder/executable; some times it can be safe to remove these to make the package smaller in size.

The folder Tools/ contains Python tools supplied in the distribution. Looking in this folder surprised me when I first saw them as they are practically examples and demos of the Python language doing something useful.

Here are some examples of these:

  • scripts/md5sum.py : «Python utility to print MD5 checksums of argument files»
  • scripts/diff.py : Finds the difference of two files. «Command-line interface to difflib.py providing diffs» in different formats.
  • scripts/google.py : Open a search term in a new browser window/tab

Owner of PyTutorials and creator of auto-py-to-exe. I enjoy making quick tutorials for people new to particular topics in Python and tools that help fix small things.

Источник

При установке Python папка Scripts — пустая

Всем привет
Решила установить Python на компьютер, но как-бы я не старалась он не устанавливается корректно. А именно: папка Script остается пустой, из-за этого возникает ошибка при попытке установки библиотеки через pip. Перепробовала все методы, даже пыталась с ноутбука с нормально установленным Python перенести папку Script на ПК, не помогло.
При попытке установить pip по инструкции с официального сайта появляется куча ошибок :
C:\Users\Dem0L!$heR>python get-pip.py
Collecting pip
Using cached https://files.pythonhosted.org. ne-any.whl
Collecting setuptools
Using cached https://files.pythonhosted.org. ne-any.whl
Collecting wheel
Using cached https://files.pythonhosted.org. ne-any.whl
Installing collected packages: pip, setuptools, wheel
ERROR: Exception:
Traceback (most recent call last):
File «C:\Users\Dem0L!$heR\AppData\Local\Programs\Python\Python37-32\lib\distutils\util.py», line 192, in subst_vars
return re.sub(r’\$([a-zA-Z_][a-zA-Z_0-9]*)’, _subst, s)
File «C:\Users\Dem0L!$heR\AppData\Local\Programs\Python\Python37-32\lib\re.py», line 192, in sub
return _compile(pattern, flags).sub(repl, string, count)
File «C:\Users\Dem0L!$heR\AppData\Local\Programs\Python\Python37-32\lib\distutils\util.py», line 189, in _subst
return os.environ[var_name]
File «C:\Users\Dem0L!$heR\AppData\Local\Programs\Python\Python37-32\lib\os.py», line 678, in __getitem__
raise KeyError(key) from None
KeyError: ‘heR’

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File «C:\Users\DEM0L!~1\AppData\Local\Temp\tmptztth1ou\pip.zip\pip\_internal\cli\base _command.py», line 188, in main
status = self.run(options, args)
File «C:\Users\DEM0L!~1\AppData\Local\Temp\tmptztth1ou\pip.zip\pip\_internal\commands \install.py», line 407, in run
use_user_site=options.use_user_site,
File «C:\Users\DEM0L!~1\AppData\Local\Temp\tmptztth1ou\pip.zip\pip\_internal\req\__in it__.py», line 58, in install_given_reqs
**kwargs
File «C:\Users\DEM0L!~1\AppData\Local\Temp\tmptztth1ou\pip.zip\pip\_internal\req\req_ install.py», line 928, in install
use_user_site=use_user_site, pycompile=pycompile,
File «C:\Users\DEM0L!~1\AppData\Local\Temp\tmptztth1ou\pip.zip\pip\_internal\req\req_ install.py», line 461, in move_wheel_files
warn_script_location=warn_script_location,
File «C:\Users\DEM0L!~1\AppData\Local\Temp\tmptztth1ou\pip.zip\pip\_internal\wheel.py «, line 326, in move_wheel_files
prefix=prefix,
File «C:\Users\DEM0L!~1\AppData\Local\Temp\tmptztth1ou\pip.zip\pip\_internal\location s.py», line 111, in distutils_scheme
i.finalize_options()
File «C:\Users\Dem0L!$heR\AppData\Local\Programs\Python\Python37-32\lib\distutils\command\install.py», line 307, in finalize_options
self.expand_basedirs()
File «C:\Users\Dem0L!$heR\AppData\Local\Programs\Python\Python37-32\lib\distutils\command\install.py», line 475, in expand_basedirs
self._expand_attrs([‘install_base’, ‘install_platbase’, ‘root’])
File «C:\Users\Dem0L!$heR\AppData\Local\Programs\Python\Python37-32\lib\distutils\command\install.py», line 469, in _expand_attrs
val = subst_vars(val, self.config_vars)
File «C:\Users\Dem0L!$heR\AppData\Local\Programs\Python\Python37-32\lib\distutils\util.py», line 194, in subst_vars
raise ValueError(«invalid variable ‘$%s'» % var)
ValueError: invalid variable ‘$’heR»

За помощь заранее спасибо)

Пустая папка Scripts
В общем, загорелся я изучить Python, да только есть проблема. При установке папка scripts пустая.

Не создается папка Scripts при подключении Ajax
Добрый вечер) Добавила Microsoft.jQuery.Unobtrusive.Ajax в зависимости проекта, но папка Scripts.

Создается пустая папка при создании приложения
При вводе в терминал команды ‘python manage.py startapp core’, вместо приложения django создается.

Пустая папка src при создании проекта
Здравствуйте. Начал изучать программирование на android но столкнулся сразу же с проблемами. При.

Эксперт Python

Лучший ответ

Сообщение было отмечено kira_sisad как решение

Решение

версия ОС, версия питона, которую пыталась установить, при установке были ошибки?

1 решение (в лоб) удалить корректно питон, проверить и зачистить за ним все папки, удалить из переменных окружения PYTHONPATH, если есть. Создать в корне папку python (никаких моих документов, юзеров и прочего, просто в корень, если винда то на диск С). Скачать питон и установить туда, при установке выбрать -прописать питонпас

Источник

Оцените статью