Downloaded package ImportError - python

I have recently installed python 2.17.14 to use a package which I installed in the command prompt with:
python -m pip install packageName
However, whenever I try to use it with a script provided by the package authors, I get Import Errors:
ImportError: cannot import X from YX
ImportError: attempted relative import with no known parent package.
I don't know what I'm doing wrong, as I am really new to Python. Does anyone have any ideas?
The package is called neurodesign and I downloaded the try out script from the official website "neuropowertools.org"
Best,
Max

In case anyone (who is also new to python^^) fails ridiculously at this task as well: I had to manually install all the modules used within this package for it to work as they weren't installed automatically.

Related

I’m not able to import my pip module after installing it from my CMD

I just installed camelcase using the pip command on my cmd.
When I try pip list, the module is present but when I try to import it to my text editor, it tells me that it does not exist.
I installed another module and I was able to import it.
I’ve tried uninstalling and reinstalling it again but it’s not still working.
Which code editor are you using? In my case when I had similar problems with installing packages I tried installing them directly from terminal in my PyCharm app. For me it worked out perfectly.
Make sure you are importing the right class.
from camelcase import CamelCase

Module importing works in python console (pycharm) but not works on terminal

Hi i'm recently working on a module in python (package named pykiwoom)
I installed a module in conda 32-bit environment pip install pykiwoom and tried to import this
from pykiwoom.kiwoom import Kiwoom
This works perfectly fine when I execute this in python console in pycharm
However, when I try this in terminal error occurs
ModuleNotFoundError: No module named 'pykiwoom.kiwoom'; 'pykiwoom' is not a package
internal structure of package pykiwoom looks like this
pykiwoom
init.py
kiwoom.py
parser.py
Can somebody tell me why this error occurs?
I think where you install your package is important in your case. You can check the packages installed using pip list in terminal, and check if you find it there.
This solution provides overview of how to setup your files as packages and modules.
Nevertheless, I think if you install your package in the terminal using pip, you could possibly access it.

Trying to import GitHub module

I'm trying to import https://github.com/chrisconlan/algorithmic-trading-with-python in my code. I've never imported anything from GitHub before and have looked at various other questions that have been asked on Stack Overflow regarding this problem but it just doesn't work. When I try to run the 'portfolio.py' code for example I keep getting a ModuleNotFound error for 'pypm'. What exactly is the correct way to import such a module or the whole GitHub directory?
I'm working with Visual Studio Code on Windows.
You will need to pip install the module. In your case the command you would need to run is python -m pip install -U git+https://github.com/chrisconlan/algorithmic-trading-with-python. Once you have done that you need to find the name of the module. You can do this with pip list. Find the name of the module you just installed.
Then you just stick import <module name> at the top of your code with the rest of your imports.
What i used to do in this is to clone the repository on the folder where are installed the python's packages. This is useful when you do not want to use the pip cmd tool, keeping the pip's cache memory under control.

ImportError: No module named twisted.persisted.styles

From IDLE, I tried to run a script with a newly installed scrapy 1.0.3.
I'm using a script from a friend whom it worked for (but on Windows, I'm on a Mac).
From the import of scrapy on the first line, I get this error when running the program:
ImportError: No module named twisted.persisted.styles
The whole script, if it's helpful, points to this:
Traceback (most recent call last):
File "/Users/eliasfong/tutorial/tutorial/spiders/medspider.py", line 1, in <module>
import scrapy
File "/Library/Python/2.7/site-packages/scrapy/__init__.py", line 27, in <module>
from . import _monkeypatches
File "/Library/Python/2.7/site-packages/scrapy/_monkeypatches.py", line 20, in <module>
import twisted.persisted.styles # NOQA
ImportError: No module named twisted.persisted.styles
Any suggestions on how to tackle this problem?
Just try to force the update of twisted :
pip install twisted --upgrade
That works for me with python3.4 and Scrapy==1.1.0rc1
Either twisted is installed on your mac (I highly doubt it since it's not a standard library) and for whatever reason the IDE (i'm assuming that's what you mean since you typed "idle") or the terminal you are in doesn't have your updated environment variables, meaning it doesn't understand where your default python libraries are (again I highly doubt it), or you simple do not have twisted installed on your mac. If it's not installed you have a couple of options:
The easiest way to install a python package is through pip.
If that not an option you can try homebrew which is another package manager for macs. It offers an easy way to install packages correctly.
If that still is not an option for you or you simply don't want to attempt that you can download twisted directly from here (the .bz2 since you're on a mac), click on it and it should unzip it for you. Then just run setup.py and it should install it in the correct location on your mac.
If that still doesn't work and you have decent knowledge of unix. Use the "locate" command on the terminal and find out where your dist-packages directory is and put the source for twisted in there directly and then attempt to import twisted in your IDE or in the python interpreter to verify that it is installed.
note: If you're still having problems after it is installed trying restarting your IDE or messing with some setting to make sure your IDE has the right environment and python path. Hope that helps!
It could be related to having installed Python without bzip2. I had the same error and this helped me, see the accepted answer here:
Installing Twisted through pip broken on one server
Had this exact thing on FreeBSD. Solution (as root/sudo):
chmod -R go+rX /usr/local/lib/python2.7/site-packages
Some directory permissions weren't set up right on install.

how to install PyMouse on Windows

i am trying to use PyMouse plugin on windows 8.1 .
i used this code to import library :
from pymouse.windows import PyMouse
but this error shows :
from win32api import GetSystemMetrics
ImportError: No module named
'win32api'
where is the problem? i am not sure that i install the library fine ! can you show how to install it on windows ?
The win32api module is part of PyWin32, so you need to install that.
Meanwhile, you should be installing things with pip whenever possible. Some packages aren't pip-installable, or have incorrect requirements specs, but most packages, if you try to pip install them, will either automatically fetch their dependencies or complain that they're missing.
Also it looks like PyMouse's documentation is wrong, because it claims to only require ctypes (which comes with Python 2.6+), not PyWin32, on Windows. You may want to file a documentation bug with them.
However, it looks like the PyMouse you were using was abandoned at version 0.4 about 6 years ago. It was then picked up by someone else, but, as the README says, it was later merged into PyUserInput. So, you probably want to use that instead.
Note that PyUserInput correctly mentions the other dependencies in its README. It also checks them in its setup.py file. So hopefully, all you have to do is:
pip install PyUserInput
… and it will either pull in PyWin32 and pyHook, or complain that you have to go get them manually.

Categories