Spyder not recognizing splinter - python-3.4

Though splinter is installed on my Windows Vista, spyder gives an error when I import it.
When I import in windows command prompt, it successfully imports & also shows path to the init file.
Have added explicit path in PYTHONPATH Manager of Spyder and Updated module list. Yet, did not help.
Have checked my PATH environment variable. It contains the path to Python, Python/Scripts & Python/Lib/site-packages. PATH contains no spaces and PATH is indeed named as PATH & not as Path (probably thats why able to import successfully via command prompt)
When I try to install splinter again (just to confirm if it exists or not), pip says it already exists. When I try to upgrade, pip says it is already up-to-date
Have read lots & lots of articles on stackoverflow & across the web, but no solution helped.
Spyder recognizes other packages like os, numpy, etc.
Had run this code successfully on a temporary testing machine. Now trying to run on my system and its failing with error ImportError: No module named 'splinter'
Python ver. 3.4; Spyder ver. 3.4
Hoping for a solution...
Complete trackeback:
runfile('E:/Rampy/DS/Python/Code/AGMARK.py', wdir='E:/Rampy/DS/Python/Code')
Traceback (most recent call last):
File "", line 1, in
runfile('E:/Rampy/DS/Python/Code/AGMARK.py', wdir='E:/Rampy/DS/Python/Code')
File "C:\Users\ramprasad.g\AppData\Local\Continuum\Anaconda3\lib\site->packages\spyderlib\widgets\externalshell\sitecustomize.py", line 580, in runfile
execfile(filename, namespace)
File "C:\Users\ramprasad.g\AppData\Local\Continuum\Anaconda3\lib\site->packages\spyderlib\widgets\externalshell\sitecustomize.py", line 48, in execfile
exec(compile(open(filename, 'rb').read(), filename, 'exec'), namespace)
File "E:/Rampy/DS/Python/Code/AGMARK.py", line 8, in
from splinter import Browser
ImportError: No module named 'splinter'

Okay. So, I could make it work with a work-around.
Inspite of adding C:\Python34 & its Lib (site-packages) folder to PATH environment variable and Spyder's Python Path Manager, it failed to recognize splinter package while running the code in Spyder. So, I copied & pasted Splinter (followed by Selenium) package-folders from C:\Python34\Lib\site-packages (location where PIP installed the packages) to C:\Users\ramprasad.g\AppData\Local\Continuum\Anaconda3\Lib\site-packages (Anaconda's package location which alone Spyder seems to recognize) and boom! It started working!

Related

Anaconda Navigator Jupyter and Spyder won't start after successful installation

I have installed Anaconda 3 on Windows 10 64-bit. The installation completed successfully. I could start idle.exe and it works. I can start the Anaconda Powershell and Anaconda Prompt, but I cannot start the Navigator nor Spyer or Jupyter. Launching them from the start menu will bring up the Windows shell windows for a moment, before they disappear and nothing happens.
I have tried starting the navigator from the Anaconda Prompt and this is what the error message looks like:
(base) PS C:\Users\Frank> anaconda-navigator.exe
Traceback (most recent call last):
File "C:\Users\Frank\Anaconda3\Scripts\anaconda-navigator-script.py", line 10, in <module>
sys.exit(main())
File "C:\Users\Frank\Anaconda3\lib\site-packages\anaconda_navigator\app\main.py", line 103, in main
from anaconda_navigator.app.start import start_app
File "C:\Users\Frank\Anaconda3\lib\site-packages\anaconda_navigator\app\start.py", line 34, in <module>
from anaconda_navigator.widgets.main_window import MainWindow
File "C:\Users\Frank\Anaconda3\lib\site-packages\anaconda_navigator\widgets\main_window.py", line 37, in <module>
from anaconda_navigator.utils.analytics import GATracker
File "C:\Users\Frank\Anaconda3\lib\site-packages\anaconda_navigator\utils\analytics.py", line 44, in <module>
from anaconda_navigator.external.UniversalAnalytics import Tracker
File "C:\Users\Frank\Anaconda3\lib\site-packages\anaconda_navigator\external\UniversalAnalytics\Tracker.py", line 28, in <module>
from six.moves.urllib.request import (HTTPSHandler, Request, build_opener,
ImportError: cannot import name 'HTTPSHandler' from 'six.moves.urllib.request' (unknown location)
I have searched the internet for root causes of the last line in the error message with no success. There are a few tips how to fix it, but nothing worked.
The exact version I have installed is Anaconda3-2019.10-Windows-x86_64.exe.
I have tried uninstalling and reinstalling Anaconda in all different "flavors":
for all users, without adding the path to the environment variables
for all users, with adding the path to the environment variables for
current user, without adding the path to the environment variables
for current user, with adding the path to the environment variables
Anaconda is installed into a directory without spaces in its name and no fancy characters: c:\users\frank\Anaconda3.
I have removed .anaconda and tried launching the navigator, spyer and jupyter again with no success.
Spyer comes up with a message that it had crashed during the last session. I followed the advice and deleted the .spyder-py3 folder, but no change.
How can I find more information about the reason for the problem on my system? Are there any log files that contain more information? I checked if HTTPSHandler is defined where Anaconda would search for it (please consider my limited expertise in Anaconda, when assuming where to look for resources...).
I installed the same Anaconda3 version on another computer and it works right from the start.
After reading another suggestion about updating conda using conda update conda and trying it on the Anaconda prompt I received the following error:
(base) PS C:\Users\Frank> conda update conda
Collecting package metadata (current_repodata.json): failed
CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://repo.anaconda.com/pkgs/main/win-64/current_repodata.json>
Elapsed: -
An HTTP error occurred when trying to retrieve this URL.
HTTP errors are often intermittent, and a simple retry will get you on your way.
If your current network has https://www.anaconda.com blocked, please file
a support request with your network engineering team.
SSLError(MaxRetryError('HTTPSConnectionPool(host=\'repo.anaconda.com\', port=443): Max retries exceeded with url: /pkgs/main/win-64/current_repodata.json (Caused by SSLError("Can\'t connect to HTTPS URL because the SSL module is not available."))'))
I had the idea that SSL could be a problem and uninstalled OpenSSL v1.1.0g (Win64), then checked again. That doesn't help. Installing OpenSSL v1.1.0g (Win64) again doesn't make a difference either. On the other hand I would have assumed that Anaconda brings all components and modules it needs.
Any ideas how to continue troubleshooting?
I kept digging for answers and came across a discussion at GitHub:
CondaHTTPError: Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available)
I followed the advice, uninstalled my OpenSSL version and installed the latest one from the page https://slproweb.com/products/Win32OpenSSL.html. This is now "Win64 OpenSSL v1.1.1d" and right after the installation all the issues with Anaconda were gone. I can use conda to update, the Anaconda Navigator comes up, Jupyter Notebook works. All is fine.

Symfony along with NLTK

I have a script in Python that imports out of some other packages, the NLTK package.
The OS is Debian Stretch. Executing it directly on Linux everything works as should it be. But running the mentioned script with Sympony - Process, it returns the following error:
Traceback (most recent call last):
File \"/var/www/html/public/_import.py\", line 1, in <module>
import nltk
ModuleNotFoundError: No module named 'nltk'
If simply I just comment "import nltk", all the script works properly even with Symfony Process at all.
I could not leave this problem, as I have resolved it, without an answer for you that might be facing the same issue!
The problem at all was not caused by Symfony - Process, but, unfortunatly, by instalation behavior of the module named: "NLTK";
In my case, the user used to install things on Linux Debian Stretch was the root.
Try (now, you, before changes and check...) to use the following command in your terminal: pip show nltk.
The output is:
Name: nltk
Version: 3.4.5
Summary: Natural Language Toolkit
Home-page: http://nltk.org/
Author: Steven Bird
Author-email: stevenbird1#gmail.com
License: Apache License, Version 2.0
Location: /usr/local/lib/python3.7/site-packages
Requires: six
Required-by:
Take a look at Location. Now it is the right place. But, as default, pip install nltk will place it, in my case with user "root" installing things, at "/root/.local/lib/python3.7/site-packages/nltk" as the base path! So, when the user "www-data" tried to runing it... ModuleNotFoundError: No module named 'nltk'
No module named 'nltk' - because it was not there to the place should it be accessed!
So, as you might guess now, the problem as caused by permission issues! Unfortunatly, no error (logs) output happened that would drive me to mind that would it be related to permission issues!
The solution:
1) Not messing around with the system or executing unecessary changes was considered at first place;
2) Had uninstalled it with pip the module NLTK and I have seeked to find where the other modules were installed;
3) Installed it (NLTK) again, but now, placing it where I want, I mean, where it should be since the begening: among the others modules - as numpy -, that could be accessed easily and without issues!
The command used was:
pip install --target="/usr/local/lib/python3.7/site-packages"
--upgrade nltk
Now, NLTK resides at /usr/local/lib/python3.7/site-packages followed by all the other modules working properly like a charm!
I hope this helps you!

Adding the ibapi library to PYTHONPATH module in Spyder (Python 3.6)

I am trying to simply connect to the ibapi (Interactive Brokers API), but I am having some technical troubles with Spyder.
What I did so far:
I installed the latest version for Windows from here
I provided the following path to the PYTHONPATH manager in Spyder: C:\TWS API\source\pythonclient\ibapi afterwards I restarted Spyder
When I simply type import ibapi I get the same error message: ModuleNotFoundError: No module named 'ibapi'
What I am doing wrong here and how can I fix this simple error?
I don't use python very much but I'm pretty sure you have to install the ibapi. I never used the PYTHONPATH and mine works fine in Spyder and Jupyter. I'm using Anaconda.
I run the Anaconda prompt (just activates the conda environment) and navigate to the dir C:\TWS API\source\pythonclient and run python setup.py install
Then everything works. I think many python packages need to be installed like this.
note: That's not my install dir, I just copied yours. There may be a problem with a space in the path. Try renaming to C:\TWSAPI\... if you still have a problem.
Note: after python setup.py install, you might need to restart spyder. If doesn't help, then copy the newly-created ibapi folder to:
C:\Users\iuzeri\AppData\Local\Programs\Python\Python37-32\Lib\site-packages
or
C:\Program Files (x86)\Python37-32\Lib\site-packages
copy your ibapi here
C:/ProgramData/Anaconda3/Lib/site-packages/ibapi

Openmdao: Not able to use gradient free approaches. eg: NSGA2

I am working on windows platform and have set up all my requirements for NSGA2 solver but still it is not working. I have downloaded and installed MPI, MinGW, SWIG, Pyopt, pyoptsparse but still I am unable to use the pyoptsparse driver.
If someone could help on this, it will be of a great help. Thanks
I have pasted the error below
D:\Anaconda2\Scripts\python.exe D:/OpenMDAO/Mitul/Sellar/Sellar_MDF.py
Traceback (most recent call last):
File "D:/OpenMDAO/Mitul/Sellar/Sellar_MDF.py", line 6, in <module>
from openmdao.drivers.pyoptsparse_driver import pyOptSparseDriver
File "d:\anaconda2\lib\site-packages\openmdao\drivers\pyoptsparse_driver.py", line 19, in <module>
from openmdao.core.driver import Driver
File "d:\anaconda2\lib\site-packages\openmdao\core\driver.py", line 15, in <module>
from openmdao.util.options import OptionsDictionary
ImportError: No module named options
it is difficult to get MPI and pyopt-sparse built correctly on windows. But It has been done successfully. You can see the docs here for detailed instructions
That being said... there is clearly something wrong with your OpenMDAO installation. That error implies that things are not being copied correctly into the installation folder. Since you're using anaconda, I suggest that you create a new anaconda env as follows:
conda create --name om2 python=2 numpy scipy matplotlib
then activate it with source activate om2 and try to re-install openmdao via pip. You can get the very latest by doing
pip install git+http://github.com/OpenMDAO/OpenMDAO.git#master
Once you've done that, before you try to get mpi/petsc/pyopt-sparse installed you should run our test suite. Follow our docs on that, and if the tests all pass you can move on to the other more advanced install steps.

Bokeh - Runserve.py fail

After hearing Peter Wang talk about the Bokeh plotting environment, I had to try it. The problem is I can't even get the examples to work because I can't get the plot server going. I verified the install of all listed dependencies, and installed continuumweb (a module that is curiously absent from the list of dependencies in the Bokeh README on github). However, I still encountered the error below. It looks like this should come out of continuumweb, but I find no trace of such a sub-module within the repo. Am I looking in the wrong place? (I have not found any other instances of this exception.)
If anyone could provide some guidance, I would be grateful...
choct155#choct155-U46E:~/analysis/anaconda/pkgs/Bokeh$ python runserver.py
Traceback (most recent call last):
File "runserver.py", line 3, in <module>
from bokeh.server import start
File "/home/choct155/analysis/anaconda/pkgs/Bokeh/bokeh/server/start.py", line 76, in <module>
import services
File "/home/choct155/analysis/anaconda/pkgs/Bokeh/bokeh/server/services.py", line 4, in <module>
from continuumweb.launch_process import ManagedProcess
ImportError: No module named launch_process
Exception KeyError: KeyError(139639237560272,) in <module 'threading' from '/home/choct155/analysis/anaconda/lib/python2.7/threading.pyc'> ignored
For those who are reading this later, we've had two versioned releases since the original question, and they are all easy to install directly from PyPI via "pip install bokeh". If you are using Anaconda, it's even easier to install via "conda install bokeh".
For some reason, the pip installer did not perform well here. I just started from scratch by cloning the continuumweb repository and installing from source ('python setup.py install' in the cloned directory)...
All is well.

Resources