How to add python library to Spyder - python

I am trying to add an external python library from a third party software into Spyder so I can work with it. I have already tried the following:
Adding library path containing .py files to Tools>PYTHONPATH manager
Synchronizing the path
Updating module names list through Tools>Update Module names list
However, when I try to import modules from this library I get two types of errors:
import easy
Traceback (most recent call last):
File "<ipython-input-2-685519d35f15>", line 1, in <module>
import easy
File "C:\Program Files (x86)\Plaxis\PLAXIS 2D\plxscripting\easy.py", line 24, in <module>
from .server import Server, InputProcessor
ValueError: Attempted relative import in non-package
The second type of error as follows:
from plxscripting.easy import *
Traceback (most recent call last):
File "<ipython-input-1-a40c101d3bb0>", line 1, in <module>
from plxscripting.easy import *
ImportError: No module named plxscripting.easy
I don't understand why Spyder is not recognizing these libraries. The path has been added and shows up on the manager. What constitutes a python module? Is it not just the .py file with module name prefix? Is not the path sufficient to work with the library through the IDE?

Related

Python can't find time module after I moved my application to different folder

I have a strange problem after I moved an application to a different folder. I copied all files inside the old folder to the new directory and then tried to restart the application. However when I do so I get the error message:
Traceback (most recent call last):
File "bin/zeoserver", line 24, in <module>
import plone.recipe.zeoserver.ctl
File "/usr/local/Plone/buildout-cache/eggs/plone.recipe.zeoserver-1.3.1-py2.7.egg/plone/recipe/zeoserver/__init__.py", line 1, in <module>
import logging
File "/usr/local/Plone/Python-2.7/lib/python2.7/logging/__init__.py", line 26, in <module>
import sys, os, time, cStringIO, traceback, warnings, weakref, collections
ImportError: No module named time
This is particularly intriguing as time should be a pre-installed Python package. What is also interesting is that after renaming the old folder to xyz_old I cannot start the application from there either.
What could cause such an issue?

ImportError: No module named parse python/node js

I am calling .py file from node.js using npm i cmd-node on windows it is working well and executing my .py file from .js file, but when I am deploying it on the server giving following error:
Note: I am not importing parse anywhere, it may be part if any dependency.
python script cmd error: Error: Command failed: python covert_to_csv.py
Traceback (most recent call last):
File "covert_to_csv.py", line 1, in <module>
import tabula
File "/home/ubuntu/.local/lib/python2.7/site-packages/tabula/__init__.py", line 3, in <module>
from .wrapper import (
File "/home/ubuntu/.local/lib/python2.7/site-packages/tabula/wrapper.py", line 20, in <module>
from .file_util import localize_file
File "/home/ubuntu/.local/lib/python2.7/site-packages/tabula/file_util.py", line 3, in <module>
from urllib.parse import urlparse as parse_url
ImportError: No module named parse
You are probably using different versions of python on your local machine compared to the server. Make sure it is the same version as your local machine and it'll work.

How to import self-made modules?

I created some simple modules for learning purposes containing simple classes and functions and tried to import it for the shell. Unfortunately TraceBack Error occurs.
I've checked os.getcwd() and I'm in the directory with all those modules. I also created modules with both pycharm and shell itself (open("filename","w") and stuff) and still python cannot find them.
Do you have any idea what's the reason of such matters?
import komendy
Error:
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
ModuleNotFoundError: No module named 'komendy'
They are in same folder:
>>> os.listdir()
['komendy.py', 'zmienne.py', 'venv', 'mordeczko.txt', 'mordo', '.idea']
Ideas?
You can import your library and its methods like this:
from komendy import *
Also check this:
How to import other Python files?

Error while importing localization

I downloaded the localization package in Anaconda. But when I try to import it I get the following error:
Traceback (most recent call last): File "<pyshell#0>", line 1, in <module> import localization File "~\Python\Python36-32\lib\site-packages\localization\__init__.py", line 1, in <module>
from geoProject import *
ModuleNotFoundError: No module named 'geoProject'
I do not know what to do, can someone please help me out?
"geoProject", must be your project name, not the name of the module you are trying to input.
Try:
from your module import *
or just
import yourmodule
It works if your module is in current directory. Unless you should write the full path to your module

Python error: No module named RuntimeError

Im trying to figured out this problem. Yesterday I installed PyScripter and since then, scripts doesnt work. When I run any script (in PyScripter or IDLE) and trying to "import arcpy", it gets this error:
import arcpy
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import arcpy
File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\__init__.py", line 17, in <module>
from geoprocessing import gp
File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\__init__.py", line 14, in <module>
from _base import *
File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\_base.py", line 14, in <module>
import arcgisscripting
File "C:\Python26\ArcGIS10.0\lib\arcgisscripting.py", line 81, in <module>
from RuntimeError import RuntimeError
ImportError: No module named RuntimeError
Have somebody any suggestion how to fix it?
Thanks to all very much!
Sounds like the module is not installed properly (or at all). To verify, do the following:
open a shell and start the python shell by typing python
(If this doesn't display an error, check that python is added to your system path or if it is even installed at all. But if you've used Python on said machine maybe system path issue)
enter the commmand help('modules')
review the list of modules that's returned to see whether arcpy is included
if not, then you may have to reinstall the module

Categories