Wing ide python path

Wing Python IDE

Set aspect ratio

Wing uses projects as a way to configure the environment needed by your code, and to distinguish between source files that are part of your code base (those you are likely to want to open, edit, search, etc.) and those that are just in libraries or packages that you use (and should be discovered by Wing’s code intelligence features).

Once a project has been set up from the New Projects dialog, the project’s configuration can be viewed and modified from Project Properties in the Project menu. The configuration is described in more detail in Project Properties.

To see or change which files are in your project, use the Project tool in the Tools menu, as described below.

Python Environment

Whether you do it from the New Project dialog or later in Project Properties , it is important to set up the Python environment that Wing should be using with your code. This affects the contents of the auto-completer, the display of code warnings and errors, and many other features that need to distinguish between syntactic and other differences across Python versions. It also allows Wing to find and analyze all the third party packages that you may use in your code.

In addition to setting Python Executable , you may also need to set Python Path or Environment in Project Properties so Wing can successfully find and inspect all the modules that your code uses. Setting Python Path is usually only necessary if your code modifies sys.path at runtime. Setting Environment is (relatively rarely) needed to allow Python modules to load and use DLLs.

Adding Files and Directories

Adding your source files to the project tells Wing which files you are working on, which is important for searching, Open From Project , and other features. Usually only the source base you are working on should be added to the project, while Python’s standard libraries and other frameworks and libraries used by your code can be left out of the project and instead found, as needed, through the Python Path . Packages that are installed into Python will be found automatically.

If you did not add all your source code from the New Project dialog, you can do so with Add Existing Directory in the Project menu. This allows you to control which files to include, and whether or not sub-directories are included. The list of files shown in the project updates as files matching the criteria are added and removed on disk.

Individual files can be added with Add Current File and Add Existing File .

Add New File can be used to create a new file and simultaneously add it to your project.

A subset of these options can be accessed from the context menu that appears when right-clicking on the Project tool.

Читайте также:  Array values recursive php

Removing or Omitting Files and Directories

To remove a specific file or directory, select it and use Remove Selected Entry in the Project menu or Remove/Exclude From Project in the right-click context menu on the Project tool.

If the removed file or directory is part of another directory that has been added to the project, the removal is remembered as an exclusion that can be cleared from Directory Properties , which are accessed by right clicking on the parent directory in the Project tool.

Saving a New Project

The New Project dialog automatically saves your new project if you are creating a new source directory along with it. If you selected an existing source directory or created a new blank project, then your project is created as an untitled unsaved file. In this case you will need to save it with Save Project in the Project menu. Once a project file has been saved the first time, it will be re-saved automatically as you work with Wing and there is no need to save it manually again unless you wish to move the project file, as described in the next section.

Источник

Wing Python IDE

Set aspect ratio

Python uses a search path referred to as the Python Path to find modules that are imported into code with the import statement. Most code only imports modules that are already on the default path, for example modules in the Python standard library, or modules installed into Python by pip , pipenv , conda , or some other package manager.

However, in some cases code will depend on a different path provided either by setting the environment variable PYTHONPATH before starting Python, or by modifying sys.path at runtime before importing modules.

If the Python Path is changed by one of these methods, you may also need to tell Wing about this change. This is done with Python Path in Project Properties , accessed from the Project menu:

/images/doc/en/intro/project-properties.png

For this tutorial, you need to add the subdir sub-directory of your tutorials directory to Python Path , as shown above. This directory contains a module used as part of the first coding example.

Note that the full path to the directory subdir is used. This is strongly recommended because it avoids potential problems finding source code during debugging, if the starting directory is ambiguous or changes over time. If relative paths are needed to make a project work on different machines, use an environment variable like $/subdir . This is described in more detail in Environment Variable Expansion.

The configuration used here is for illustrative purposes only. You could run the example code without altering the Python Path by moving the path_example.py file to the same location as the example scripts.

Startup Environment

Wing uses its startup environment as the default environment for your Python code. As a result, if PYTHONPATH is set when you start Wing, it will also be used with your code. If this inherited path matches the needs of your code, then you don’t need to set Python Path in Wing. However, if you have different Python environments on your system or code with different path expectations, then you should set Python Path in the project so that switching projects will also switch to the correct environment.

Читайте также:  Css как сделать зомби

Virtualenv and Anaconda Environments

If you are using virtualenv , Anaconda environments, or pipenv to set up your Python environment, you don’t need to set Python Path . Instead, set Python Executable to Activated Env and enter the command that activates your environment. This causes Wing to pick up the correct path and other environment needed to run code in the environment. In this case, Python is launched by running python in that environment.

You can also create a new virtualenv or Anaconda environment at the same time as creating a Wing project by selecting the Create New Virtualenv or Create New Anaconda Environment project types in the New Project dialog, accessed from the Project menu.

But don’t do this now; you’ll need the current project as you work through this tutorial.

Python Path Analysis

If your main entry point alters sys.path , and the file is set as the Main Entry Point in Project Properties then Wing may be able to automatically determine the correct path to use.

When in doubt, compare the value of sys.path at runtime in your code with the value reported by Show Python Environment in the Source menu. If they match then there is no need to set Python Path in your project.

Источник

Wing Python IDE

Set aspect ratio

On Windows, the executable is called wing.exe and is located in the bin directory in your Wing installation. This is not on the PATH by default, but may be added with the Windows Control Panel. In Wing Personal the executable is instead named wing-personal.exe and in Wing 101 it is named wing-101.exe .

On Linux, the executable is named wing9.1 and should be available on the PATH . The executable is also available as wing in the installation directory, which is not on the PATH by default. In Wing Personal the executable is instead named wing-personal9 and in Wing 101 it is named wing-101-9 .

On macOS, the executable is called wing and is located in Contents/Resources within the .app bundle directory. This is not on the PATH by default, but could be added either by adding that directory to PATH in ~/.profile (for example, PATH="/Applications/WingPro.app/Contents/Resources:$"; export PATH ) or by placing a symbolic link (for example, by typing sudo ln -s /Applications/WingPro.app/Contents/Resources/wing wing9.1 in a directory that is already on the PATH ). In Wing Personal the executable is instead named wing-personal and in Wing 101 it is named wing-101 .

Opening Files and Projects

Once you have established a way to start Wing from the command line, you may specify a list of files to open after the executable name. These can be arbitrary text files and a project file. For example, the following will open project file myproject.wpr and also the three source files mysource.py , README , and Makefile :

wing.exe mysource.py README Makefile myproject.wpr

Wing determines file type by extension, so position of the project file name (if any) on the command line is not important.

Читайте также:  Javascript массивы замена элемента

A line number may be specified for the first file on the command line by appending : to the file name. For example, README:100 will position the cursor at the start of line 100 of the README file.

Command Line Options

The following options may be specified anywhere on the command line:

--prefs-file=fullpath -- Add the given file to the list of preferences files that are opened by the IDE. These files are opened after the system-wide and default user preferences files, so values in them override those given in other preferences files.

--new -- By default Wing will reuse an existing running instance of Wing to open files specified on the command line. This option turns off this behavior and forces creation of a new instance of Wing. Note that a new instance is always created if no files are given on the command line.

--reuse -- Force Wing to reuse an existing running instance of Wing IDE even if there are no file names given on the command line. This just brings Wing to the front.

--settings=fullpath -- Use the given fullpath instead of the default location for the Settings Directory.

--cache=fullpath -- Use the given fullpath instead of the default location for the cache directory.

--verbose -- (Posix only) This option causes Wing to print verbose error reporting output to stderr . On Windows, run console_wing.exe instead for the same result.

--disable-updates -- Load Wing without applying any updates made since the last installation from an installer package. If you are having problems with an update, the update can be reverted from the About box.

--get-login-env=yes|no -- (macOS only) This option specifies whether Wing will get the inherited environment from a login shell. If this option is not specified, Wing will get the login environment when it is started from the Finder or via open from the command line. The login environment is the environment used when you run a shell or python in a Terminal window.

--use-winghome -- (For developers only) This option sets WINGHOME to be used during this run. It is used internally and by developers contributing to Wing. The directory to use follows this argument.

--use-src -- (For developers only) This option is used to force Wing to run from Python source files even if compiled files are present in the bin directory, as is the case after a distribution has been built.

--orig-python-path -- (For developers only) This option is used internally to indicate the original Python path in use by the user before Wing was launched. The path follows this argument.

Источник

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