7
$\begingroup$

When Get["MyPackage`"] is executed, Mathematica looks for a package in $UserBaseDirectory/Applications, and it does, it will load it.

Is there a Mathematica function that lists the installed packages installed in $UserBaseDirectory/Applications that are loadable by Get?

For example, is there something like InstalledApplications[] which returns {"MyPackage`", "OtherPackage`", ...}?

$\endgroup$
  • $\begingroup$ Not sure if it's better to ask a separate question… but how about making the goal of this question higher? In Maple packages can be loaded or unloaded through menu. Can we have something similar in Mathematica? : i.stack.imgur.com/yztaE.png $\endgroup$ – xzczd Jun 16 '18 at 6:31
  • 1
    $\begingroup$ @xzczd if my paclet server (paclets.github.io/PacletServer) takes off it'd be possible to cook in. I could also write up a palette for doing that with Wolfram's built-in paclets too. $\endgroup$ – b3m2a1 Jun 16 '18 at 8:02
7
$\begingroup$

There's nothing truly built in, but this is easy to roll if you know how to work with paclets. PacletInformation will return a "Context" parameter that specifies contexts for that paclet that may be loaded by Get. PacletFind[] will return all paclets. So then just attach the ".m" and ".wl" files and you get:

Sort@DeleteDuplicates@Join[
   FileBaseName[#] <> "`" & /@ 
    FileNames[WordCharacter .. ~~ (".m" | ".wl"), $Path],
   Select[
    Flatten@Lookup[PacletInformation /@ PacletFind[], "Context"],
    StringMatchQ[(WordCharacter | "`") ..]
    ]
   ]

{"Alexa`", "AmhCode`", "AnatomyGraphics3D`", \
"AnatomyGraphics3DLoader`", "ArduinoCompile`", "ArduinoLink`", \
"ArduinoUpload`", "Arxiv`", "ArXivLoad`", \
"AstronomyConvenienceFunctions`", \
"AstronomyConvenienceFunctionsLoader`", "AuthDialogs`", \
"Authentication`", "AVRCCompiler`", "AWSLink`", "Benchmarking`", \
"BingSearch`", "BingSearchFunctions`", "BingSearchLoad`", \
"BlockBuilder`", "BTools`", "CacheManager`", "CCodeGenerator`", \
"CCompilerDriver`", "ChannelFramework`", "ChannelFrameworkLoader`", \
"ChatSystem`", "ChatTools`", "ChatToolsLoader`", "ChemSpider`", \
"ChemSpiderLoad`", "ChemTools`", "CloudExpression`", \
"CloudExpressionLoader`", "CloudObject`", "CloudObjectLoader`", \
"CodeSeal`", "CodeSeal`Authoring`", "CompiledFunctionTools`", \
"CompoundMatrixMethod`", "CoursewareTools`", "CrossRef`", \
"CrossRefLoad`", "Cryptography`", "CUDALink`", "CURLLink`", \
"DAALLink`", "Databases`", "DataDropClient`", \
"DataDropClientLoader`", "DataResource`", "DataResourceLoader`", \
"Dataset`", "DatasetLoader`", "DemoChannels`Oneliner`", \
"DemoChannels`WIM`", "Developer`", "DeviceFramework`Devices`", \
"DocFind`", "DocGen`", "DocumentationBuild`", "Dropbox`", \
"DynamicWebImage`", "EmbedCode`", "EmbedCodeLoader`", \
"EmbeddedService`", "EmbeddedServiceLoader`", "EncodedCache`", \
"EntityFramework`", "EntityFrameworkLoader`", "ExcelUpdate`", \
"ExceptionHandling`", "Experimental`", "ExtendedTools`", \
"ExternalEvaluate`", "ExternalEvaluateLoader`", \
"ExternalEvaluatePython`", "Facebook`", "FacebookLoad`", "Factual`", \
"FactualFunctions`", "FactualLoad`", "FDLLink`", \
"FederalReserveEconomicData`", "FederalReserveEconomicDataLoad`", \
"FEInfoExtractor`", "FETools`", "FileBrowser`", "Firmata`", \
"Fitbit`", "FitbitFunctions`", "FitbitLoad`", "Flickr`", \
"FlickrLoad`", "Forms`", "FormsLoader`", "FormulaData`", \
"FormulaDataLoader`", "FrontEndGraphics`", "GeneralUtilities`", \
"GeneralUtilitiesLoader`", "GeoFieldModelData`", \
"GeoFieldModelDataLoader`", "GitBookBuilder`", "GitConnection`", \
"GoogleAnalytics`", "GoogleAnalyticsLoad`", "GoogleCalendar`", \
"GoogleCalendarLoad`", "GoogleContacts`", "GoogleContactsLoad`", \
"GoogleCustomSearch`", "GoogleCustomSearchFunctions`", \
"GoogleCustomSearchLoad`", "GooglePlus`", "GooglePlusLoad`", \
"GoogleTranslate`", "GoogleTranslateFunctions`", \
"GoogleTranslateLoad`", "GPUTools`", "HDF5Tools`", "HTTPClient`", \
"HTTPHandling`", "HTTPLink`", "HTTPLinkLoader`", "HTTPListen`", \
"HumanGrowthData`", "HumanGrowthDataLoader`", "Iconize`", \
"IconizeLoader`", "IGraphM`", "IMAPLink`", "IMAPLinkLoader`", \
"InflationAdjust`", "InflationAdjustLoader`", "init`", "Instagram`", \
"InstagramLoad`", "IntegratedServices`", "IntegratedServicesLoader`", \
"Interpreter`", "IPOPTLink`", "JavaGraphics`", "JLink`", \
"JSONStream`", "LightGBMLink`", "LinearAlgebra`", "LinkedIn`", \
"LinkedInLoad`", "MachineLearning`", "MachineLearningLoader`", \
"Macros`", "MacrosLoader`", "MailChimp`", "MailChimpLoad`", \
"MailLink`", "MailLinkLoader`", "MaTeX`", \
"MathematicalFunctionData`", "MathematicalFunctionDataLoader`", \
"MicrosoftTranslator`", "MicrosoftTranslatorFunctions`", \
"MicrosoftTranslatorLoad`", "MiscFuncs`", "Mixpanel`", \
"MixpanelFunctions`", "MixpanelLoad`", "MobileMessaging`", \
"MobileMessagingLoader`", "MoleculeViewer`", "MongoLink`", \
"MQTTLink`", "MSETools`", "MTools`", "MUnit`", "MUnitLoader`", \
"MXNetLink`", "MyProjects`", "NaturalLanguageProcessing`", \
"NaturalLanguageProcessingLoader`", "NDSolve`FEM`", "NETLink`", \
"NeuralFunctions`", "NeuralNetResource`", "NeuralNetworks`", \
"NotebookTabbing`", "NotebookToPackage`", "NumericArrayUtilities`", \
"OAuth`", "OAuthLoader`", "OAuthSigning`", "OldHelpBrowser`", \
"OpenCLLink`", "OpenLibrary`", "OpenLibraryFunctions`", \
"OpenLibraryLoad`", "OpenPHACTS`", "OpenPHACTSLoad`", \
"PackageDataPacletInstall`", "PacletManager`", "PaneFileBrowser`", \
"PLI`", "PLILoader`", "PredictiveInterface`", "PresenterTools`", \
"ProcessLink`", "ProcessLinkLoader`", "PubChem`", "PubChemLoad`", \
"PublicPacletServer`", "PubMed`", "PubMedLoad`", "Pushbullet`", \
"PushbulletAPIFunctions`", "PushbulletLoad`", "PyTools`", \
"QuantityUnits`", "QuantityUnitsLoader`", "Reddit`", \
"RedditFunctions`", "RedditLoad`", "ResizePane`", \
"ResourceSystemClient`", "ResourceSystemInternalTools`", \
"ResourceSystemInternalToolsLoader`", "RobotTools`", \
"RobotToolsLoader`", "RunKeeper`", "RunKeeperLoad`", \
"SearchBrowser`", "SeatGeek`", "SeatGeekLoad`", "SecureShellLink`", \
"SemanticImport`", "SemanticImportLoader`", "SETools`", \
"Sheepshead`", "SketchTemplate`", "SMTPLink`", "SMTPLinkLoader`", \
"SpellCorrect`", "SpellCorrectLoader`", "SpellingData`", \
"SpellingDataLoader`", "StandardOceanData`", \
"StandardOceanDataLoader`", "StoppingPowerData`", \
"StoppingPowerDataLoader`", "Streaming`", "StreamingLoader`", \
"StreamLink`", "StylesheetEdit`", "SurveyMonkey`", \
"SurveyMonkeyLoad`", "SymbolicMachineLearning`", \
"SymbolicMachineLearningLoader`", "SymbolObjects`", \
"SyntaxHighlighting`", "SystemInstall`", "SystemInstallLoader`", \
"SystemTest`", "SystemTools`", "Templating`", "Terminal`", \
"TestApp`", "TetGenLink`", "TextSearch`", "TextSearchLoader`", \
"TextTranslation`", "TextTranslationLoader`", "TINSLink`", \
"Transmogrify`", "TravelDirectionsClient`", \
"TravelDirectionsClientLoader`", "TriangleLink`", "Twilio`", \
"TwilioFunctions`", "TwilioLoad`", "TwilioSendMessage`", "Twitter`", \
"TwitterFunctions`", "TwitterLoad`", "TypeSystem`", \
"TypeSystemLoader`", "URLUtilities`", "UWTools`", "VernierLink`", \
"WebSearch`", "WebSearchLoader`", "WebUnit`", "WebUnit`Utilities`", \
"WebUnit`WebDriverAPI`", "Wikipedia`", "WikipediaData`", \
"WikipediaDataLoader`", "WikipediaFunctions`", "WikipediaLoad`", \
"WolframAlphaClient`", "WolframBlockchain`", \
"WolframBlockchainLoader`", "WolframScript`", "WordFrequency`", \
"WordFrequencyLoader`", "WSM`", "WSMLink`", "WSMLoader`", "Yelp`", \
"YelpFunctions`", "YelpLoad`", "ZeroMQLink`", "ZeroMQLinkLoader`"}
$\endgroup$
  • $\begingroup$ "DatabaseLink`" is oddly missing. $\endgroup$ – Edmund Jun 16 '18 at 19:54
  • $\begingroup$ @Edmund that may be a holdover from when I used it in v10. It could have installed the paclet then but been removed in v11. This obviously reflects the state of my machine only. $\endgroup$ – b3m2a1 Jun 16 '18 at 19:55
6
$\begingroup$

There is no foolproof way to do this. Packages may be installed in very different ways. The other answer talks about paclets. Here's something for non-paclet packages.

candidates = Catenate[
   Function[path,
     FileNameTake[#] <> "`" & /@ 
      Select[FileNames[All, path], DirectoryQ]
     ] /@ $Path
   ];

Select[candidates, FindFile[#] =!= $Failed &]

This enumerates all directories within paths contained in $Path. Then it appends a backtick to turn them into context names. If FindFile can resolve a context name to a loadable file, it is kept. Otherwise, it is thrown out.

It does give false positives that are not packages, but to be fair, these false positives are in face loadable with <<name`, even if they are not meant to.

It also misses packages which are loadable by <<name`subname`.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.