"ModuleNotFoundError: No module named 'tgan'" - python

I tried installing a package called 'tgan' (which is relatively new) but I keep getting
ModuleNotFoundError: No module named 'tgan'
I made sure that my requirements satisfy the package (python 3.5,3.6 or 3.7) and I installed tgan using pip on the CMD, as well as Conda. However, when I try to install it directly on my IDE (Spyder) I get the following error:
pip install tgan
Note: you may need to restart the kernel to use updated packages.
The filename, directory name, or volume label syntax is incorrect.
Here's my full code:
from tgan.model import TGANModel
import pandas as pd
all_data = pd.read_excel('C:/Users/Mahmoud164033/Desktop/Conference Paper/ML
Models/Compiled_data.xlsx', sheet_name= 'c1,4', header = 0)
data = all_data.iloc[:,2:].values
continuous_columns = [4]
tgan = TGANModel(continuous_columns)
model = tgan.fit(data)
Here's the documentation:
https://sdv.dev/TGAN/
Update: It turns out that I had Python 3.8 installed on Conda (the documentation says it only works with Python 3.5,3.6 and 3.7) and after downgrading to Python 3.7.5 the package works.

Actually, I am not using that package until you said but I try it to install that and it installs version 0.0 but I supposed you want to latest version(0.1.0). So try this way.
pip install tgan==0.1.0
And another thing is they require pandas>=0.23.4 and tensorflow<2.0,>=1.13.0
Plz concern that also.

Related

Python Firebase (Real-time database) on Replit

I want to connect to firebase on replit using python. I'm using the code below:
from firebase import firebase
firebase = firebase.FirebaseApplication("my firebase url", None)
data = {
'ddfjaklfbja': 'dklabja;kdlf',
'adfjlkgadjf': 'dkaljbaowq',
'afbiouadofpia': 'dsajklbjanzm'
}
result = firebase.post('/test1', data)
print(result)
However, when I try to run it, it returns an error saying that there is no module named urllib3:
ModuleNotFoundError: No module named 'urllib3'
When I try to use the packages tab to install it on the left, it does not install and returns with the same error (there are multiple lines but the last line says this). How can I fix it?
Their are multiple things you can try:
Open your command prompt and enter "pip install urllib3"
If it can't install it try this: python3 -m pip install urllib3 or pip3 install urllib3
Perhaps it helps when you add this to your python file: import urllib3
this issue is related to Python path, and with the python interpreter. Make sure you are using the python interpreter in which you have installed the modules. (If using 3.9 use python 3.9 as interpreter as opposed to 3.10). If this doesnt work check python path. Other easy solution is to change your project folder to one that imported your modules correctly.

spacy ImportError: cannot import name Deque in Jupyter Notebook

I want to use spacy in a Python project on Juptyer Notebook but when i try to import the module I get the Error "ImportError: cannot import name Deque". I installed spacy in PyCharm in my virtual env via pip install -U spacy
I've seen another question on here that was similar (ImportError cannot import name Deque with spacy) but I can import spacy in PyCharm just fine so I assume it's a Jupyter Notebook specific problem.
I also checked the spacy version on PyCharm and JN and they're both the same, however it seems like my virtual env and JN don't use the same Python Version (3.8.1 in my venv on PyCharm and 3.6.0 on JN)
[Python Versions in PyCharm and JN]
May that be the problem or is something else causing it?
I also tried to uninstall and install again in PyCharm but it didn't change anything and also tried to pip install spacy in JN again but that also didn't solve it, JN told me I might have to restart the kernel but after restarting it still couldn't import spacy without that error.
I've tried so much that after some time i just get the error ImportError: cannot import name errors but I assume it's still the same problme.
I'm very grateful for any suggestions and tips!
So for future references:
I just 'solved' this problem by making a new environment with Python 3.6 since afaik Jupyter Notebook doesn't support Python versions highter than 3.6.x as of now yet, set up a new venv and now both PyCharm and JN use the same Python version (3.6.12) and I could successfully import spacy.
So I'm assuming the different Python versions really were the problem.
Maybe it's not even necessary to create a new venv and everything but I wanted to start clean again to not have further problems.

No module named 'xlsxwriter' after installing module into virtual environment [duplicate]

I recently downloaded the xlsxwriter version 0.6.4 and installed it on my computer. It correctly added it to my C:\Python27\Lib\site-packages\xlsxwriter folder, however when I try to import it I get the error ImportError: No module named xlsxwriter. The traceback is File "F:\Working\ArcGIS\ArcGIS .py\Scripts\Append_Geodatabase.py".
However if I try to import numpy (I can't remember what numby is, however it is located in the same site-packages folder C:\Python27\Lib\site-packages\numpy) it has no problem.
Any idea of what could be causing this issue?
Thanks for the help.
Here are some easy way to get you up and running with the XlsxWriter module.The first step is to install the XlsxWriter module.The pip installer is the preferred method for installing Python modules from PyPI, the Python Package Index:
sudo pip install xlsxwriter
Note
Windows users can omit sudo at the start of the command.
Even if it looks like the module is installed, as far as Python is concerned it isn't since it throws that exception.
Try installing the module again using one of the installation methods shown in the XlsxWriter docs and look out for any installation errors.
If there are none then run a sample program like the following:
import xlsxwriter
workbook = xlsxwriter.Workbook('hello.xlsx')
worksheet = workbook.add_worksheet()
worksheet.write('A1', 'Hello world')
workbook.close()
I have the same issue. It seems that pip is the problem. Try
pip uninstall xlsxwriter
easy_install xlsxwriter
I managed to resolve this issue as follows...
Be careful, make sure you understand the IDE you're using! - Because I didn't.
I was trying to import xlsxwriter using PyCharm and was returning this error.
Assuming you have already attempted the pip installation (sudo pip install xlsxwriter) via your cmd prompt, try using another IDE e.g. Geany - & import xlsxwriter.
I tried this and Geany was importing the library fine. I opened PyCharm and navigated to 'File>Settings>Project:>Project Interpreter' xlslwriter was listed though intriguingly I couldn't import it! I double clicked xlsxwriter and hit 'install Package'... And thats it! It worked!
Hope this helps...
sudo pip install XlsxWriter
Make sure that X and W are in uppercase.
I am not sure what caused this but it went all well once I changed the path name from Lib into lib and I was finally able to make it work.
I installed it by using a wheel file that can be found at this location:
https://pypi.org/project/XlsxWriter/#files
I then ran pip install "XlsxWriter-1.2.8-py2.py3-none-any.whl"
Processing ./XlsxWriter-1.2.8-py2.py3-none-any.whl
Installing collected packages: XlsxWriter
Successfully installed XlsxWriter-1.2.8
in VSCode:
instead of activating your environment with script use python select interpreter
from VSCode(press ctrl + shift + p)
and then select your environment from the list (marked with recommended)
I found the same error when using xlsxwriter in my test.py application. First, check if you have xlsxwriter module installed or not.
sudo pip install xlsxwriter
Then check the python version you are using, The following worked for me
python2 test.py
Using this on Raspberry Pi 4. I had a similar issue. I followed the install step:
sudo pip install xlsxwriter
None of the IDEs could find the module. I had to use Add/Remove Software under preferences in the GUI, search for xlsxwriter, select one by clicking on it and make sure the box is checked, and then click apply, then select the other one (it showed two for me) and click apply for that one. After that, it worked fine.

Downloaded package ImportError

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.

No Module Named xlutils.copy and pip install fail

I am getting an error message that says "no module named xlutils.copy". When I got to do the pip install of xlutils.copy I get an error message "could not find a version that satifies the requirement". I downloaded xlutils 2.0.0 which contains xlutils.copy but I am not sure if it needs to be put in a certain directory?
from xlrd import open_workbook
from xlutils.copy import copy
rb = open_workbook('Excel FDT Master_01_update.xlsx')
wb = copy(rb)
s = rb.sheet_by_name('INPUT')
r = 5
for test in col_test:
s.cell(rowx = r, colx = 1).value = test
r += 1
wb.save('comeonenow.xls')
Perhaps you have multiple installations of Python, and the pip installed the xlutils in a different installation. If you try just:
import xlutils
I expect you'll get the same results as before. I feel this may be getting overlooked by some of the other posters. Your error message says it can't find the xlutils module, not some submodule or variable. Is this still the case?
When you have multiple installations of Python, only one is the "default", so to speak, and any module installations will install into that default Python installation. I am careful to only run two installations: Python 2.7 and 3.6. And I go into each installation and make sure that I have a pip2 and a python2, and a pip3 and python3, so that I can just reference directly to the Py version I want to use, either to run or to install new packages. Otherwise, if I just run pip, I'm not 1000% sure where it will go. (Okay, I'm exaggerating. I know Python 2 is my default. Just trying to make a point.) :)
Also, just because you think you only have one Python installation, that may not be the case. On Windows, yes. But on Mac, there is a preloaded Python installation, and updating the Python and getting new packages into the new version instead of the preloaded version can be tricky, depending on what you've done. Also, when you install an IDE like PyCharm, it wants to install a Python version, as well.
Last comment -- Sometimes (not usually but sometimes), an installed package will have a different name than you would think. That is not the case with xlutils. But, with fonttools, you install fonttools but you must import fontTools (note the capital 'T') into your Py script. Again, not the case with xlutils, but just be aware of this for the future.

Categories