how to get spyder's python recognize external packages on MacOS X? - python

I have spyderlib installed on my MacOS X (10.6.8) using the official dmg file. In parallel, I have installed packages using both pip and homebrew from the terminal (i.e. opencv, gdal...). As Spyder is using its own python version, I cannot access my external packages within Spyder.
When Homebrew install a package, it instals it in the /usr/local/lib... directory, which is not avalaible to add using the Python Path manager of Spyder.The entire directory /usr/... is hidden.
The only relevant similar case I found online was the following:
Adding a module (Specifically pymorph) to Spyder (Python IDE)
I have tried unsuccessfuly their recommendations. So two related questions to tackle the problem:
1- would it be possible to actually use in Spyder the same python as the one accessed in the terminal?
2- otherwise, how to add external packages to the Spyder's original python, when the packages are installed in the folder /usr/local... ?
Thanks

I don't use a mac, but I would go with option 1, building and installing Spyder on your regular Python.
Install PyQt4 if you don't have it:
brew install pyqt
Then download the Spyder 2.2.5 source (spyder-2.2.5.zip) from here, unzip the folder where you like.
Then open a terminal, and go inside the Spyder source folder (you must input the next commands from inside this folder).
Then build using your regular python executable:
python setup.py build
and install:
python setup.py install
If all dependencies are met, you should then have Spyder as a package under your main Python installation. There should be a script to execute it under the Scripts folder.
You can also see "Install or run directly from source" from the main Spyder installation page.

Related

'robot is not recognized as an internal or external command'

Problem: I am trying to running my Dummy.robot test script in the terminal via cmd line: robot -d results tests/dummy.robot. However, it is returning the error 'robot' is not recognized as an internal or external command. I sensed that perhaps the robotframework was not properly installed or in the correct directory because the keywords "Open Browser" (see below) was already detected as invalid syntax prior to running.
Troubleshooting Methods:
Checked that both robotframework and robotframework-seleniumlibarary were installed
Installed intellibot on PyCharm and restarted IDE
Made sure I provided the correct path to the script within my project directory as shown below.
Checked that Python 39 and Python39/Scripts was added to my PATH although I am not sure if this is relevant because it just allows me to use pip for installing robotframework later.
Selected the interpreter for this "dummy" project from where that python.exe is located.
Source Screenshots:
File Structure
Run Config & Updated File Structure (3/8/21)
Source Code
Terminal
RF Library Location
I think, going by your terminal pic, it looks like you have a virtual environment: (base). As #TodorMinakov suggested, fire the command pip list in your terminal path (same path as shown in the pic). If Robot Framework libs exist there, then it should be fine. Then try the command python -m robot -d results tests/dummy.robot But if libs are not in the folder, then you have to do pip install for them from Terminal for right installation (which means, your installed libs are in your native directory while you are working in virtual env).
Since you are working with Pycharm IDE, it is better if you could use its terminal instead of using a command line tool such as bash or command prompt. Try this too.
To check if the libs installed are in System Python, you have to go to your folder site packages (eg: C://Python39/Lib/site-packages), you would find all the natively installed libraries here. In case of virtual environment, you have to check in your present directory (where the code exists). There should be a folder by the name venv (or 'base'), which will comprise of the python paths eg: (venv/Lib/site-packages)
I have experienced the same issue and it was a pip versioning issue. It got resolved after installing the upgraded pip version and then reinstalling the robot framework and Appium library. Thanks
Use the terminal in Admin mode.
pip uninstall robotframework
upgrade pip
again pip install robotframework

How to install a new python module on VSCode?

I'm trying to install new python modules on my computer and I know how to install through the terminal, but I wish to know if there is a way to install a new module directly through VSCode (like it is possible on PyCharm)?
I already installed through the terminal, it isn't a problem, but I want to install without be obligate to open the terminal when I'm working on VSCode.
You should open the terminal inside the VSCode and install the modules you want.
something like👇
if that's not you meant, please let me know.
First of all I would advise you to select the current Python version you have. It has been explained here:
VSCode: There is no Pip installer available in the selected environment
Next, you should check is the pip installed in your Python main directory or not, by checking how to do on this website:
https://pip.pypa.io/en/stable/installing/
or this thread
How to use pip with Visual Studio Code
by typing
py -m pip
in your terminal, like
C:\Users\m\Desktop\Python> py -m pip
You should have the list of commands and general options which can be used. One of them is install
On the Python library platform, you always have the command to be copied in order to the installation of package you want.
In your terminal, the initial command should look as:
PS C:\Users\m\Desktop\Python> py -m
to which you should append the command prepared on the Python library platform (by copying it and pasting).
C:\Users\m\Desktop\Python> py -m pip install openpyxl
That's it. The package should be installed in your Python folder, what you will see in the terminal.
If everything is alright, you just need to type
import openpyxl #or other package name, which you downloaded
and use it!
Unfortunately! for now, only possible way is terminal.

Installing local package to PyCharm

I am trying to install a custom Python 3 package into PyCharm. The package comes with a setup.py file. In PyCharm's Project Interpreter settings, I tried adding the local directory (according to these instructions) which contains the setup.py file but the package is not registering when I reload the list of available packages to install. Tried adding the directory which includes the .egg file but to no avail either. How am I supposed to install custom packages? Is there a command line I could use instead for PyCharm?
Using PyCharm Pro v3.4 on OSX Yosemite.
I ended up setting up a virtual environment (using virtualenvwrapper), installing the python packages there, and then pointing the Project Interpreter within PyCharm to the python version sitting within the virtual environment.

Matplotlab .exe file for Python 3.4 cannot find path to Python34

I am running Windows and am a beginner python user trying to install a few modules to run a python script. I have Python 2.7.9 and 3.4.2 both installed to the C:\ directory. I downloaded matplotlib-1.4.3.win-amd64-py3.4.exe and the corresponding .exe for python 2.7 from the Matplotlib website, but when I run the py3.4 exe the program cannot find Python 3.4 to update (Cannot install: Python version 3.4 is required, which is not found in the registry).
Python 2.7 installer works perfectly. Is there a misset PATH variable in Windows I can modify so the .exe can function properly? In CMD 'Python --version' returns Python 3.4, so unsure how to fix the issue. I installed these months ago, and may have put them in Downloads before transferring both to C:\ for clarity, which may be the problem but am unsure how to fix it.
Also, if your answer involves pip in any way please clarify how exactly to use pip in Windows. A lot of websites say to run eg. 'pip setup.py install' in the 'terminal' but do not specify if they mean Windows CMD terminal, IDLE GUI, or Python.exe command-line interface. Thanks a lot!
Not the answer to your actual question, but some clarification on your last point:
but do not specify if they mean Windows CMD terminal, IDLE GUI, or
Python.exe command-line interface.
Yes, this requires to know some context that a beginner may not have. The command pip is always used in the CMD terminal. So open CMD, and enter
pip3 install matplotlib
Notes:
Use pip3 when installing for Python 3. Then you're certain you're not accidentally installing libraries for Python 2.
pip setup.py install does not exist. You're mixing up two mechanisms to install Python packages/libraries:
One uses pip, with aforementioned pip3 install <something>. Pip goes looking online, finds a corresponding package name in a database, retrieves the URL for that package, downloads the package and installs the package. All in one command.
python3 setup.py install (again explicitly use python3 or python2 to be sure) requires you to find the package, download it, unzip it, and then in the CMD terminal, inside the unzipped folder, run the python3 setup.py install command.
This second method is usually for the latest-greatest version of a package that is not yet in pip's database, or for packages that never were in pip's database in the first place.
Generally, as a beginner, you want to stick with pip. If you ever run into the issue with the package not being available via pip, you may still be able to use pip for downloading and installing, like for example so:
pip install https://github.com/matplotlib/matplotlib/archive/master.zip
which would install the most recent matplotlib (which won't have even a version number yet, so bugs could be around).
All of these commands happen in the CMD terminal: downloading/installing packages generally all go through the terminal.
Also, when people mention "terminal", they will mean (for Windows) something like the CMD terminal. When it has to be done inside Python, it is generally called the "Python prompt". (IDLE is yet a different beast, that I'm not familiar with. I'm guessing that it has several parts, including a text editor section and a Python prompt section.)

pyinstaller --version failed to create a process

I would like to use PyInstaller to create a Windows executable. I installed pyinstaller using pip, as well as the correct version of pywin32.
When I attempt to verify the pyinstaller installation by typing pyinstaller --version, I get the message failed to create a process.
What am I doing wrong? Thanks in advance for your help.
There could be two reasons:
1) The python install location has spaces. See the answer at https://stackoverflow.com/a/34546220/3559967
2) You renamed the python install location. See the answer at https://stackoverflow.com/a/17560177/3559967
You can always reinstall pyinstaller:
python -m pip uninstall pyinstaller
[output of uninstall]
python -m pip install pyinstaller
where python is the command you use to run the python version of your choice (py, python, python3, etc.).
Notes:
Moving or changing exe names (i.e. the python.exe filename), folders, etc. can cause issues, per the other answer. If you want to make changes to the python exe or it's location, you typically need to do that immediately upon install, before installing any other packages.
There are ways of recording all your existing packages (See PIP Freeze) to a requirements.txt file, and then reinstalling them later, for another version of Python or to a new virtual environment.
If you are not familiar with virtual environments, you can start learning in the Python venv package docs. Note that you should never rename or move a venv folder after creating it (but it's easy to create a new one and reinstall the packages).

Categories

Resources